micropython/bluetooth/aioble: subscribe must register the connection.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/433/head
Jim Mussared 2021-07-08 15:12:20 +10:00
rodzic 2e91b92413
commit 32684886ee
1 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -377,6 +377,9 @@ class ClientCharacteristic(BaseClientCharacteristic):
# Write to the Client Characteristic Configuration to subscribe to
# notify/indications for this characteristic.
async def subscribe(self, notify=True, indicate=False):
# Ensure that the generated notifications are dispatched in case the app
# hasn't awaited on notified/indicated yet.
self._register_with_connection()
if cccd := await self.descriptor(bluetooth.UUID(_CCCD_UUID)):
await cccd.write(struct.pack("<H", _CCCD_NOTIFY * notify + _CCCD_INDICATE * indicate))
else: