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.
Dependents: BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more
Diff: public/BLEDevice.h
- Revision:
- 294:ab928e365ea1
- Parent:
- 293:6278354cfd98
- Child:
- 295:4883b219983a
--- 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.
+ */
+ ble_error_t onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP));
+ template <typename T> ble_error_t 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);
@@ -553,6 +567,16 @@
transport->getGattServer().setOnDataWritten(objPtr, memberPtr);
}
+inline ble_error_t
+BLEDevice::onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) {
+ return transport->getGattServer().setOnDataRead(callback);
+}
+
+template <typename T> inline ble_error_t
+BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) {
+ return transport->getGattServer().setOnDataRead(objPtr, memberPtr);
+}
+
inline void
BLEDevice::onUpdatesEnabled(GattServer::EventCallback_t callback)
{