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.
Fork of BLE_API by
Diff: ble/Gap.h
- Revision:
- 921:ea542e6519bb
- Parent:
- 920:d18cff0c4b09
- Child:
- 922:e04837405cd5
--- a/ble/Gap.h Thu Nov 26 12:52:04 2015 +0000 +++ b/ble/Gap.h Thu Nov 26 12:52:04 2015 +0000 @@ -140,9 +140,12 @@ return (durationInMillis * 1000) / UNIT_1_25_MS; } + typedef FunctionPointerWithContext<TimeoutSource_t> TimeoutEventCallback_t; + typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> TimeoutEventCallbackChain_t; - typedef void (*TimeoutEventCallback_t)(TimeoutSource_t source); - typedef void (*ConnectionEventCallback_t)(const ConnectionCallbackParams_t *params); + typedef FunctionPointerWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallback_t; + typedef CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallbackChain_t; + typedef void (*DisconnectionEventCallback_t)(const DisconnectionCallbackParams_t *params); typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t; @@ -893,7 +896,13 @@ * Set up a callback for timeout events. Refer to TimeoutSource_t for * possible event types. */ - void onTimeout(TimeoutEventCallback_t callback) {timeoutCallback = callback;} + void onTimeout(TimeoutEventCallback_t callback) { + timeoutCallbackChain.add(callback); + } + + TimeoutEventCallbackChain_t& onTimeout() { + return timeoutCallbackChain; + } /** * Append to a chain of callbacks to be invoked upon GAP connection. @@ -903,6 +912,10 @@ template<typename T> void onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t*)) {connectionCallChain.add(tptr, mptr);} + ConnectionEventCallbackChain_t& onconnection() { + return connectionCallChain; + } + /** * Append to a chain of callbacks to be invoked upon GAP disconnection. */ @@ -956,7 +969,7 @@ _scanResponse(), state(), scanningActive(false), - timeoutCallback(NULL), + timeoutCallbackChain(), radioNotificationCallback(), onAdvertisementReport(), connectionCallChain(), @@ -1002,8 +1015,8 @@ } void processTimeoutEvent(TimeoutSource_t source) { - if (timeoutCallback) { - timeoutCallback(source); + if (timeoutCallbackChain) { + timeoutCallbackChain(source); } } @@ -1017,10 +1030,10 @@ bool scanningActive; protected: - TimeoutEventCallback_t timeoutCallback; + TimeoutEventCallbackChain_t timeoutCallbackChain; RadioNotificationEventCallback_t radioNotificationCallback; AdvertisementReportCallback_t onAdvertisementReport; - CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t*> connectionCallChain; + ConnectionEventCallbackChain_t connectionCallChain; CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> disconnectionCallChain; private: