NordicSemiconductor / pc-ble-driver-py

Python bindings for the ble-driver library
Other
126 stars 115 forks source link

BLE Adapter: support enabling notifications on CCCD #20

Closed peabody124 closed 7 years ago

peabody124 commented 7 years ago

This is needed for the buttonless DFU CCCD

peabody124 commented 7 years ago

I'm trying to write a script that kicks a device like the buttonless DFU app into DFU mode. This seems to almost work ( https://gist.github.com/peabody124/ec1f037506e498dc66c4ddfbce2a5997 ). The device repeats back the correct value (like when using nRF Connect). However it never quite completes. As best as I can tell, that is because the characteristic is an indication and it needs to be acknowledged. I can't find anything in the python code that does that. Any suggestions?

bihanssen commented 7 years ago

There are some parts missing to make indications work properly.

Currently only notification events are being propagated: https://github.com/NordicSemiconductor/pc-ble-driver-py/blob/master/python/pc_ble_driver_py/ble_adapter.py#L427. Indications will need to be propagated too.

It is also necessary to add handling of indications, and for that it is necessary to call sd_ble_gattc_hv_confirm which is currently not implemented in ble_driver.py.

mrodem commented 7 years ago

Indication support was added in PR #28. This also included the missing parts that were pointed out by @bihanssen.

peabody124 commented 7 years ago

Awesome, thank you!