How do you register for a BLE characteristic Notification/Indication events (BLE central/client)

I am working on a BLE central application (client function) using MBED OS 6.

My external BLE peripheral device uses the NOTIFY property.

As such, I need my MBED BLE central application to enable notifications for that characteristic.

Unfortunately, I cannot find much information about how to go about this.

We have a small paragraph here within “the details”:

And somehow I need to incorporate all data here:

But that’s it.

Laboriously trawling through the OS code, does not give much more about the function I need, which is found within the GattClient.h file…

* Register an handler for Handle Value Notification/Indication events.
* @param callback Event handler to register.
* @note It is possible to unregister a callback by using
* onHVX().detach(callbackToRemove).
void onHVX(HVXCallback_t callback);

As you see the code documentation does not tell me much.

So, assuming this is the right function, how do I attach this to a particular characteristic handle for example.

Then where should I place this code - I assume this “onHVX” is best placed within the discovery_termination function, if I was using the LEDblinker example as my reference.

Any guidance, is greatly appreciated.



Enabling the notify is proving quite difficult to find.

Using the LEDblinker example as my guide, I have added in an option for HVX within the LEDBlinkerDemo class:


Then added a new function “trigger_hvx”

void trigger_hvx(const GattHVXCallbackParams *response) { ... }

BUT… I cannot find out how to enable the characteristic NOTIFY property so that this callback triggers. I need to find some way of getting the CCCD attribute first.

I’ve discovered that the handling of CCCD and writing this attribute to enable notify is covered in the example BLE_GattClient, but it almost seems as if the coders want to rather demonstrate their superior prowess at C++ than try and simplify all the BLE examples for learning purposes by creating an easy to understand and well documented structure. Instead the structure of this example is completely different to the others, without any explanation as to why.

Hence, I now find myself trying to fit this “square peg” into the “round” BLE_LEDBlinker example, and this is proving quite difficult as the descriptor class also requires call backs etc. So this looks like a rejigging of the whole example.

As mentioned before, any guidance is greatly appreciated.


my exact feeling when I read the examples…

1 Like