Neil,
Apologies for my previous handwaving; and thanks for driving me to a response.
I'll give you a quick answer as a start. This might help you in case you're hoping to get something working in short order.
The CCCD attribute handle is very likely going to be the characteristic's valueHandle + 1. This isn't a guarantee, but would most likely be the case. So you can use GattClient::write(char.getValueHandle() + 1, ...) and get things going for now. Please keep in mind that CCCD is a uint16_t bitmap. This is not the proper or portable solution; for that please read on.
It could be that what's needed here is a simple API like: DiscoveredCharacteristic::enableNotification(), but then that would allow manipulation of only the CCCD. There may be other writable descriptors, which would then require a more generic API.
There's an API meant to discover descriptors for a Characteristic.
https://github.com/mbedmicro/BLE_API/blob/master/ble/DiscoveredCharacteristic.h#L117
Unfortunately, I haven't implemented it for the nRF51 yet. The default implementation remains in effect: https://github.com/mbedmicro/BLE_API/blob/master/source/DiscoveredCharacteristic.cpp#L63
My thinking is that launching descriptor discovery should result in callbacks passing the DiscoveredDescriptors (which is a datatype which needs to be added to BLE_API). I'm not sure how best to handle the discovered descriptors following the callback. Perhaps they should be contained within the owning characteristic, or perhaps the user would issue reads/writes directly upon the discovered descriptors.
I'll be tied up with other things for the coming days/weeks. It would be lovely if the community comes together and proposes a solution (or even a pull request).
thanks.
Hello Community,
We now have experimental support for GattClient. I'd like your feedback, and this will most likely bake for a while before we push it to mbed.org. But you can begin using it.
Here's an initial demo: https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_LEDBlinker/
It won't build on mbed.org. But you can combine it with the following to brew something useful: BLE_API https://github.com/mbedmicro/BLE_API/tree/gattClient nRF51822 https://github.com/mbedmicro/nRF51822/tree/gattClient
I'm sorry for making you use offline builds to combine these.
The demo drives an LED service exported by a BLE_LED peripheral. It demonstrates scanning, connections, service-discovery, and reads/writes.
Looking forward to your input.