Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Diff: public/BLEDevice.h
- Revision:
- 259:a95264ad705c
- Parent:
- 257:7a50601356cc
- Child:
- 260:ea7f9f14cc15
--- a/public/BLEDevice.h Wed Jan 21 09:32:48 2015 +0000 +++ b/public/BLEDevice.h Wed Jan 21 09:32:48 2015 +0000 @@ -225,8 +225,16 @@ /** * Setup a callback for the GATT event DATA_SENT. + * + * @Note: it is possible to chain together multiple onDataSent callbacks + * (potentially from different modules of an application) to receive updates + * to characteristics. + * + * @Note: it is also possible to setup a callback into a member function of + * some object. */ - void onDataSent(GattServer::ServerEventCallbackWithCount_t callback); + void onDataSent(void (*callback)(unsigned count)); + template <typename T> void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)); /** * Setup a callback for when a characteristic has its value updated by a @@ -525,11 +533,15 @@ } inline void -BLEDevice::onDataSent(GattServer::ServerEventCallbackWithCount_t callback) -{ +BLEDevice::onDataSent(void (*callback)(unsigned count)) { transport->getGattServer().setOnDataSent(callback); } +template <typename T> inline void +BLEDevice::onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) { + transport->getGattServer().setOnDataSent(objPtr, memberPtr); +} + inline void BLEDevice::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) { transport->getGattServer().setOnDataWritten(callback);