ble icon indicating copy to clipboard operation
ble copied to clipboard

Initial version of the setCCCD API for GattClient

Open andresag01 opened this issue 9 years ago • 2 comments

This is an initial version of an API that automates the process of setting the Client Characteristic Configuration Descriptor (CCCD) to enable/disable notifications. The new API is DiscoveredCharacteristic::setCCCD().

The new API internally triggers a characteristic descriptor discovery procedure to find the handle of the CCCD. If this succeeds, it attempts to execute a write procedure. On termination, a user configured callback is executed to report the final outcome of the process.

NOTE: This pull request is NOT READY FOR MERGE, it is an early version of the new API to start discussion around this issue. In my opinion, there are still a few problems that need to be tackled:

  1. Shutdown should gracefully terminate the setCCCD procedure.
  2. CCCDSetter::launch (and OneShotWriteCallback::launch, OneShotReadCallback::launch as well) do not return ble_error_t, so its impossible to check whether they actually succeeded.

@pan- Please comment.

andresag01 avatar Jan 20 '16 16:01 andresag01

The build will fail because there is a problem in the API when registering onShutdown callbacks. The signature of the function should be void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)) rather than void onShutdown(T *objPtr, void (T::*memberPtr)(void))

I have made a PR to solve this issue: https://github.com/ARMmbed/ble/pull/174

andresag01 avatar Jan 22 '16 14:01 andresag01

It seems that the ble-nrf51822 implementation of the API does shutdown the Service Discovery but NOT the Characteristic Descriptor Discoverer. I have raised an issue about this, see https://github.com/ARMmbed/ble-nrf51822/issues/110. In this case, the CCCDSetter objects will never receive the expected callbacks and the memory resources allocated will never be cleared.

andresag01 avatar Jan 22 '16 16:01 andresag01