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:
- 292:b5ee2ada4f33
- Parent:
- 290:aafa664ba829
- Child:
- 293:6278354cfd98
diff -r 0b66dd15728e -r b5ee2ada4f33 public/BLEDevice.h
--- 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);