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: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Revision 1140:dd2f69fad8c6, committed 2016-04-06
- Comitter:
- LancasterUniversity
- Date:
- Wed Apr 06 18:40:40 2016 +0100
- Parent:
- 1139:9af191d14c05
- Commit message:
- Synchronized with git rev bbc2dc58
Author: Joe Finney
microbit: Additional callback to indicate to applications when System
Attributes require initialisation from persistent storage.
Changed in this revision
--- a/ble/GattCallbackParamTypes.h Wed Apr 06 18:40:39 2016 +0100
+++ b/ble/GattCallbackParamTypes.h Wed Apr 06 18:40:40 2016 +0100
@@ -44,6 +44,10 @@
const uint8_t *data; /* @note: Data might not persist beyond the callback; make a local copy if needed. */
};
+struct GattSysAttrMissingCallbackParams {
+ Gap::Handle_t connHandle;
+};
+
enum GattAuthCallbackReply_t {
AUTH_CALLBACK_REPLY_SUCCESS = 0x00, /**< Success. */
AUTH_CALLBACK_REPLY_ATTERR_INVALID_HANDLE = 0x0101, /**< ATT Error: Invalid attribute handle. */
--- a/ble/GattServer.h Wed Apr 06 18:40:39 2016 +0100
+++ b/ble/GattServer.h Wed Apr 06 18:40:40 2016 +0100
@@ -39,6 +39,9 @@
typedef FunctionPointerWithContext<const GattServer *> GattServerShutdownCallback_t;
typedef CallChainOfFunctionPointersWithContext<const GattServer *> GattServerShutdownCallbackChain_t;
+ typedef FunctionPointerWithContext<const GattSysAttrMissingCallbackParams*> SysAttrMissingCallback_t;
+ typedef CallChainOfFunctionPointersWithContext<const GattSysAttrMissingCallbackParams*> SysAttrMissingCallbackChain_t;
+
typedef FunctionPointerWithContext<GattAttribute::Handle_t> EventCallback_t;
protected:
@@ -48,6 +51,7 @@
dataSentCallChain(),
dataWrittenCallChain(),
dataReadCallChain(),
+ sysAttrMissingCallChain(),
updatesEnabledCallback(NULL),
updatesDisabledCallback(NULL),
confirmationReceivedCallback(NULL) {
@@ -317,6 +321,36 @@
}
/**
+ * Set up a callback for when asystem descriptor (CCCD) is missing.
+ * This may be raised in response to a BLE profile change om a bonded connection.
+ * This callback provides the opportunity for user applications to restore
+ * CCCD state at the appropriate time.
+ *
+ * @Note: It is possible to chain together multiple onSysAttrMissing callbacks
+ * (potentially from different modules of an application), although it is unlikely
+ * that this will be beneficial.
+ *
+ * @Note: It is also possible to set up a callback into a member function of
+ * some object.
+ *
+ * @Note It is possible to unregister a callback using onSysAttrMissing().detach(callback)
+ */
+ void onSysAttrMissing(const SysAttrMissingCallback_t& callback) {sysAttrMissingCallChain.add(callback);}
+ template <typename T>
+ void onSysAttrMissing(T *objPtr, void (T::*memberPtr)(const GattSysAttrMissingCallbackParams* connectionHandle)) {
+ sysAttrMissingCallChain.add(objPtr, memberPtr);
+ }
+
+ /**
+ * @brief provide access to the callchain of data written event callbacks
+ * It is possible to register callbacks using onDataWritten().add(callback);
+ * It is possible to unregister callbacks using onDataWritten().detach(callback)
+ * @return The data written event callbacks chain
+ */
+ SysAttrMissingCallbackChain_t& onSysAttrMissing() {
+ return sysAttrMissingCallChain;
+ }
+ /**
* Setup a callback to be invoked on the peripheral when an attribute is
* being read by a remote client.
*
@@ -417,6 +451,10 @@
/* Entry points for the underlying stack to report events back to the user. */
protected:
+ void handleSysAttrMissingEvent(const GattSysAttrMissingCallbackParams *params) {
+ sysAttrMissingCallChain.call(params);
+ }
+
void handleDataWrittenEvent(const GattWriteCallbackParams *params) {
dataWrittenCallChain.call(params);
}
@@ -476,6 +514,7 @@
dataSentCallChain.clear();
dataWrittenCallChain.clear();
dataReadCallChain.clear();
+ sysAttrMissingCallChain.clear();
updatesEnabledCallback = NULL;
updatesDisabledCallback = NULL;
confirmationReceivedCallback = NULL;
@@ -491,6 +530,7 @@
DataSentCallbackChain_t dataSentCallChain;
DataWrittenCallbackChain_t dataWrittenCallChain;
DataReadCallbackChain_t dataReadCallChain;
+ SysAttrMissingCallbackChain_t sysAttrMissingCallChain;
GattServerShutdownCallbackChain_t shutdownCallChain;
EventCallback_t updatesEnabledCallback;
EventCallback_t updatesDisabledCallback;
--- a/ble/GattServerEvents.h Wed Apr 06 18:40:39 2016 +0100
+++ b/ble/GattServerEvents.h Wed Apr 06 18:40:40 2016 +0100
@@ -32,7 +32,7 @@
GATT_EVENT_UPDATES_DISABLED = 4, /**< Notify/Indicate disabled in CCCD. */
GATT_EVENT_CONFIRMATION_RECEIVED = 5, /**< Response received from Indicate message. */
GATT_EVENT_READ_AUTHORIZATION_REQ = 6, /**< Request application to authorize read. */
- GATT_EVENT_WRITE_AUTHORIZATION_REQ = 7, /**< Request application to authorize write. */
+ GATT_EVENT_WRITE_AUTHORIZATION_REQ = 7 /**< Request application to authorize write. */
} gattEvent_t;
};
