bleak_sigspec

Bleak Logo

Bleak SIG Bluetooth Characteristic Specification Formatter

This package enables characteristic metadata parsing and automatic formatting (bytes unpacking) into the proper characteristic values.

Features

Installation

Install bleak_sigspec by running:

$ pip install bleak_sigspec

Or get latest development version:

$ pip install https://github.com/Carglglz/bleak_sigspec.git

Usage

Example: service_explorer.py in bleak examples:

from bleak_sigspec.utils import get_char_value
[...]
37
   bytes_value = bytes(await client.read_gatt_char(char.uuid))
   formatted_value = get_char_value(bytes_value, char)
[...]
43
   log.info(
     "Characteristic Name: {0}, Bytes Value: {1}, Formatted
     Value: {2}".format(char.description, bytes_value, formatted_value))

Output

$ python3 service_explorer.py
[...]
Characteristic Name: Temperature, Bytes Value: b'Z\x16', Formatted Value: {'Temperature': {'Quantity': 'thermodynamic temperature',
'Unit': 'degree celsius',
'Symbol': '°C',
'Value': 57.22}}

Example: See characteristic metadata

>>> from bleak_sigspec.utils import get_xml_char
>>> temp = get_xml_char('Temperature')
>>> temp
Characteristic Metadata:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- NAME: Temperature
- UUID: 2A6E
- ABSTRACT: None
- SUMMARY: None
- FIELDS:
    - Temperature:
        - InformativeText: Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius
        - Requirement: Mandatory
        - Format: sint16
        - Ctype: h
        - Unit_id: org.bluetooth.unit.thermodynamic_temperature.degree_celsius
        - Quantity: thermodynamic temperature
        - Unit: degree celsius
        - Symbol: °C
        - DecimalExponent: -2
- TYPE: org.bluetooth.characteristic.temperature
- INFO TEXT: Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius
- DESCRIPTION: None
- NOTE: None
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

>>>

License

The project is licensed under the MIT license.

Indices and tables