Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
Fork of BLE_API by
Diff: public/BLEDevice.h
- Revision:
- 292:b5ee2ada4f33
- Parent:
- 290:aafa664ba829
- Child:
- 293:6278354cfd98
--- a/public/BLEDevice.h Mon Mar 02 11:50:47 2015 +0000 +++ b/public/BLEDevice.h Mon Mar 02 11:50:47 2015 +0000 @@ -252,6 +252,20 @@ void onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)); template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)); + /** + * Setup a callback for when a characteristic is being read by a client. + * + * @Note: it is possible to chain together multiple onDataRead callbacks + * (potentially from different modules of an application) to receive updates + * to characteristics. Services may add their own onDataRead callbacks + * behind the scenes to trap interesting events. + * + * @Note: it is also possible to setup a callback into a member function of + * some object. + */ + void onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)); + template <typename T> void onDataRead(T * objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)); + void onUpdatesEnabled(GattServer::EventCallback_t callback); void onUpdatesDisabled(GattServer::EventCallback_t callback); void onConfirmationReceived(GattServer::EventCallback_t callback); @@ -554,6 +568,16 @@ } inline void +BLEDevice::onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) { + transport->getGattServer().setOnDataRead(callback); +} + +template <typename T> inline void +BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) { + transport->getGattServer().setOnDataRead(objPtr, memberPtr); +} + +inline void BLEDevice::onUpdatesEnabled(GattServer::EventCallback_t callback) { transport->getGattServer().setOnUpdatesEnabled(callback);