gattlib-py/device: Add support to unregister GATT notification

fix-build
Olivier Martin 2022-05-14 00:14:53 +02:00 committed by Olivier Martin
parent 59820e2cad
commit 20f2d5facf
2 changed files with 6 additions and 0 deletions

View File

@ -222,6 +222,9 @@ class Device:
self._gatt_characteristic_callbacks[gatt_characteristic.short_uuid] = { 'callback': callback, 'user_data': user_data }
def _notification_remove_gatt_characteristic_callback(self, gatt_characteristic):
self._gatt_characteristic_callbacks[gatt_characteristic.short_uuid] = None
def __str__(self):
name = self._name
if name:

View File

@ -115,6 +115,9 @@ class GattCharacteristic():
def register_notification(self, callback, user_data=None):
self._device._notification_add_gatt_characteristic_callback(self, callback, user_data)
def unregister_notification(self):
self._device._notification_remove_gatt_characteristic_callback(self)
def notification_start(self):
ret = gattlib_notification_start(self.connection, self._gattlib_characteristic.uuid)
handle_return(ret)