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/GattServer.h
- Revision:
- 547:f84c514eee35
- Parent:
- 539:0b6e82025358
- Child:
- 548:623e4c0f0b6e
--- a/public/GattServer.h Fri Jun 19 15:52:09 2015 +0100
+++ b/public/GattServer.h Fri Jun 19 15:52:09 2015 +0100
@@ -34,7 +34,7 @@
GattServer() :
serviceCount(0),
characteristicCount(0),
- onDataSent(),
+ dataSentCallChain(),
onDataWritten(),
onDataRead(),
onUpdatesEnabled(NULL),
@@ -143,11 +143,23 @@
// be sure to call sd_ble_gatts_hvx() twice with notify then indicate!
// Strange use case, but valid and must be covered!
- void setOnDataSent(void (*callback)(unsigned count)) {onDataSent.add(callback);}
+ /**
+ * Add a callback for the GATT event DATA_SENT (which is triggered when
+ * updates are sent out by GATT in the form of notifications).
+ *
+ * @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(void (*callback)(unsigned count)) {dataSentCallChain.add(callback);}
template <typename T>
- void setOnDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) {
- onDataSent.add(objPtr, memberPtr);
+ void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) {
+ dataSentCallChain.add(objPtr, memberPtr);
}
+
void setOnDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {onDataWritten.add(callback);}
template <typename T>
void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) {
@@ -218,8 +230,8 @@
}
void handleDataSentEvent(unsigned count) {
- if (onDataSent.hasCallbacksAttached()) {
- onDataSent.call(count);
+ if (dataSentCallChain.hasCallbacksAttached()) {
+ dataSentCallChain.call(count);
}
}
@@ -228,7 +240,7 @@
uint8_t characteristicCount;
private:
- CallChainOfFunctionPointersWithContext<unsigned> onDataSent;
+ CallChainOfFunctionPointersWithContext<unsigned> dataSentCallChain;
CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams *> onDataWritten;
CallChainOfFunctionPointersWithContext<const GattReadCallbackParams *> onDataRead;
EventCallback_t onUpdatesEnabled;