getsenic / gatt-python

Bluetooth GATT SDK for Python
MIT License
318 stars 86 forks source link

How to read descriptors of characteristics? #35

Open jlusiardi opened 5 years ago

jlusiardi commented 5 years ago

Hi,

i am trying to use gatt-python to tinker around with homekit accessories (for https://github.com/jlusiardi/homekit_python) communicating via bluetooth le. Descriptors seem to be important there so i wonder how to read them via gatt-python.

https://www.bluetooth.com/specifications/gatt/generic-attributes-overview mentions them and also they are visible via bluez and dbus.

Perhaps we need to add those to the code at all?

Regards Joachim

larsblumberg commented 5 years ago

Hi Joachim,

there's no need to know or understand descriptors with this library. What you need is to know the UUID of the service and the UUID of its characteristic you want to read from / write to.

If you don't know the services' UUIDs of your HomeKit device then you can simply list all service UUIds and their characteristics via the services_resolved() callback.

Please check the documentation and let me know if you have any more questions.

jlusiardi commented 5 years ago

Hi Lars,

i guess the UUIDs are not the problem. HomeKit uses characteristic instance IDs to access characteristics (e.g. via HAP-Characteristic-Signature-Read-Request). Those characteristic instance IDs seem to be given on special descriptors (UUID dc46f0fe-81d2-4616-b5d9-6abdd796939a) of the characteristics one wants to access. For example the following excerpt:

S 00000055-0000-1000-8000-0026bb765291
     C 00000050-0000-1000-8000-0026bb765291
         D CharacteristicInstanceID/dc46f0fe-81d2-4616-b5d9-6abdd796939a 13
     C 0000004e-0000-1000-8000-0026bb765291
         D CharacteristicInstanceID/dc46f0fe-81d2-4616-b5d9-6abdd796939a 11
     C 0000004c-0000-1000-8000-0026bb765291
         D CharacteristicInstanceID/dc46f0fe-81d2-4616-b5d9-6abdd796939a 10
     C 0000004f-0000-1000-8000-0026bb765291
         D CharacteristicInstanceID/dc46f0fe-81d2-4616-b5d9-6abdd796939a 12
     C ServiceInstanceId/e604e95d-a759-4817-87d3-aa005083a0d1 9

I extracted this after doing a little patch to this library.

Regards Joachim