My code looks like this:
Code: Select all
_GNSS_BASE_UUID = ubluetooth.UUID("c33a0000-bda8-4293-b836-10dd6d78e7a1")
_GNSS_BASE_LATITUDE = (
ubluetooth.UUID(0x2AAE),
_FLAG_READ | _FLAG_NOTIFY,
((ubluetooth.UUID(0x2904), _FLAG_READ),)
)
_GNSS_BASE_SERVICE = (
_GNSS_BASE_UUID,
(_GNSS_BASE_LATITUDE,) )
)
class BLEGNSSBasePeripheral:
def __init__(self, ble, name="GNSSbase"):
self._ble = ble
self._ble.active(True)
((self._h_latitude, self._h_descr_latitude),) = self._ble.gatts_register_services((_GNSS_BASE_SERVICE,))
# Format as a 32-bit float, with 10^0 exponent, and as planar degrees.
self._ble.gatts_write(self._h_descr_latitude, struct.pack('<BbHBH', 20, 0, 0x2763, 1, 0x0000))
self._ble.gatts_write(self._h_latitude, struct.pack('<f', 23.42))
<etc>
Unfortunately I can't find any examples on setting descriptors, indeed on the web in general most tutorials just set the CCCD and leave it at that.
-JD