Exemplo n.º 1
0
from bleak import BleakClient
from bleak.uuids import uuid16_dict
import matplotlib.pyplot as plt
import matplotlib
""" Predefined UUID (Universal Unique Identifier) mapping are based on Heart Rate GATT service Protocol that most
Fitness/Heart Rate device manufacturer follow (Polar H10 in this case) to obtain a specific response input from 
the device acting as an API """

uuid16_dict = {v: k for k, v in uuid16_dict.items()}

## This is the device MAC ID, please update with your device ID
ADDRESS = "D4:52:48:88:EA:04"

## UUID for model number ##
MODEL_NBR_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Model Number String"))

## UUID for manufacturer name ##
MANUFACTURER_NAME_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Manufacturer Name String"))

## UUID for battery level ##
BATTERY_LEVEL_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Battery Level"))

## UUID for connection establsihment with device ##
PMD_SERVICE = "FB005C80-02E7-F387-1CAD-8ACD2D8DF0C8"

## UUID for Request of stream settings ##
PMD_CONTROL = "FB005C81-02E7-F387-1CAD-8ACD2D8DF0C8"
Exemplo n.º 2
0
import argparse

from bleak import BleakClient
from bleak import BleakScanner
from bleak import _logger as logger
from bleak.uuids import uuid16_dict

from datetime import datetime
from pymongo import MongoClient

# sensortag uuids

uuid16_dict = {v: k for k, v in uuid16_dict.items()}

SYSTEM_ID_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("System ID")
)
MODEL_NBR_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Model Number String")
)
DEVICE_NAME_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Device Name")
)
FIRMWARE_REV_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Firmware Revision String")
)
HARDWARE_REV_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Hardware Revision String")
)
SOFTWARE_REV_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Software Revision String")
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

import asyncio
import pytest

from common.fixtures import BoardAllocator, ClientAllocator
from bleak           import BleakClient
from bleak.uuids     import uuid16_dict

uuid16_dict = {v: k for k, v in uuid16_dict.items()}

UUID_ALERT_LEVEL_CHAR = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("Alert Level")
)

UUID_DISCONNECTION_REASON_CHAR = "f43620d0-779d-11eb-9439-0242ac130002"

CONNECTION_TIMEOUT = bytearray(b'\x08')

NO_ALERT   = bytearray(b'\x00')
MILD_ALERT = bytearray(b'\x01')
HIGH_ALERT = bytearray(b'\x02')

alert_timeout = 5


@pytest.fixture(scope="function")
async def board(board_allocator: BoardAllocator):
Exemplo n.º 4
0
def UUID(uname):
    return "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
        uuid16_dict.get(uname))
Exemplo n.º 5
0
    if type(short) == str:
        pass
    elif type(short) == int:
        hex_form = hex(short)[2:]
    else:
        raise TypeError

    return f'0000{hex_form}-0000-1000-8000-00805f9b34fb'


UUID_FOTA_SERVICE = "53880000-65fd-4651-ba8e-91527f06c887"
UUID_BINARY_STREAM_CHAR = "53880001-65fd-4651-ba8e-91527f06c887"
UUID_CONTROL_CHAR = "53880002-65fd-4651-ba8e-91527f06c887"
UUID_STATUS_CHAR = "53880003-65fd-4651-ba8e-91527f06c887"
UUID_VERSION_CHAR = "53880004-65fd-4651-ba8e-91527f06c887"
UUID_FIRMWARE_REVISION_STRING_CHAR = short_bt_sig_uuid_to_long(uuid16_dict.get("Firmware Revision String"))
UUID_DEVICE_INFORMATION_SERVICE_UUID = short_bt_sig_uuid_to_long(uuid16_dict.get("Device Information"))
UUID_DESCRIPTOR_CUDD = short_bt_sig_uuid_to_long(uuid16_dict.get("Characteristic User Description"))

FOTA_STATUS_OK = bytearray(b'\x00')
FOTA_STATUS_UPDATE_SUCCESSFUL = bytearray(b'\x01')
FOTA_STATUS_XOFF = bytearray(b'\x02')
FOTA_STATUS_XON = bytearray(b'\x03')
FOTA_STATUS_SYNC_LOST = bytearray(b'\x04')
FOTA_STATUS_UNSPECIFIED_ERROR = bytearray(b'\x05')
FOTA_STATUS_VALIDATION_FAILURE = bytearray(b'\x06')
FOTA_STATUS_INSTALLATION_FAILURE = bytearray(b'\x07')
FOTA_STATUS_OUT_OF_MEMORY = bytearray(b'\x08')
FOTA_STATUS_MEMORY_ERROR = bytearray(b'\x09')
FOTA_STATUS_HARDWARE_ERROR = bytearray(b'\x0a')
FOTA_STATUS_NO_FOTA_SESSION = bytearray(b'\x0b')
Exemplo n.º 6
0
from bleak.uuids import uuid16_dict

import numpy as np
import matplotlib.pyplot as plt



g_CumulativeOld = 10
g_Last_revolution_event_time_Old = 0.0


uuid16_dict = {v: k for k, v in uuid16_dict.items()}

# I/O test points on SensorTag.
IO_DATA_CHAR_UUID = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(
    uuid16_dict.get("CSC Measurement")
)



def openPowerCurve(filename):
    file = open(filename)
    output = []
    for line in file:

        if line[-1:] == '\n' :
            tuple = (int(line[:-1].split(',', 1 )[0]),int(line[:-1].split(',', 1 )[1]))
        else :
            tuple = (int(line.split(',', 1 )[0]),int(line.split(',', 1 )[1]))
        output.append(tuple)