able
able copied to clipboard
Receiving data through notifications
Hi, I really love the simplicity of this library for managing a GATT client. I just wanted to check my understanding about receiving data through notifications. Am i right in thinking that i enable it with "enable_notifications" (in dispatcher.py) and then "on_characteristic_changed" (in dispatcher.py) will be called when a notification for that characteristic is received. So i just have to somehow override the stub callback function "on_characteristic_changed" to handle the data being received?
Thanks!
Hi @ilw , Yes, you are right, that's how it's supposed to work.
class BLE(able.BluetoothDispatcher):
def on_services(self, status, services):
characteristic = self.services.search("aaaa")
if self.enable_notifications(characteristic):
Logger.info("Notifications enabled")
def on_characteristic_changed(self, characteristic):
data = characteristic.getStringValue(0)
And here is example of usage in the BLE functions testing app: https://github.com/b3b/able/blob/master/testapps/bletest/main.py#L222