Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
BLE gattServer onUpdatesEnabled callback type
Hi,
Sorry for the really simple beginners question, but I'm trying to register a callback to the BLE API's GATT server event 'onUpdatesEnabled'.
A BLE instance is the main class for working with Bluetooth LE:
BLE &ble = BLE::Instance();
The BLE object exposes the GATT server, which has a function for registering callbacks for its onUpdatesEnabled event. The signature of the function is:
void onUpdatesEnabled(EventCallback_t callback)
The EventCallback_t type is defined as:
typedef FunctionPointerWithContext<GattAttribute::Handle_t> EventCallback_t;
So, I've created a function called onUpdatesEnabledCallback like so:
void onUpdatesEnabledCallback(GattAttribute::Handle_t *handle) { // Do stuff }
and I try to register the callback using:
ble.gattServer().onUpdatesEnabled(onUpdatesEnabledCallback);
But I get the following compile error:
Quote:
Error: No suitable constructor exists to convert from "void (GattAttribute::Handle_t *)" to "FunctionPointerWithContext<GattAttribute::Handle_t>" in "ButtonService.h", Line: 47, Col: 44
What am I missing please?
Thanks
1 Answer
7 years, 3 months ago.
The method should be void onUpdatesEnabledCallback(GattAttribute::Handle_t handle) { Do stuff }
The parameter is the handle, not pointer to handle.