jgh
Fork of BLE_API by
Diff: ble/Gap.h
- Revision:
- 966:9451b90bbb66
- Parent:
- 956:21f1330d61de
- Child:
- 969:61f13bc8edbf
diff -r 212c16f6247f -r 9451b90bbb66 ble/Gap.h --- a/ble/Gap.h Thu Nov 26 12:52:34 2015 +0000 +++ b/ble/Gap.h Thu Nov 26 12:52:34 2015 +0000 @@ -140,15 +140,10 @@ return (durationInMillis * 1000) / UNIT_1_25_MS; } - typedef FunctionPointerWithContext<TimeoutSource_t> TimeoutEventCallback_t; - typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> TimeoutEventCallbackChain_t; - typedef FunctionPointerWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallback_t; - typedef CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallbackChain_t; - - typedef FunctionPointerWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallback_t; - typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallbackChain_t; - + typedef void (*TimeoutEventCallback_t)(TimeoutSource_t source); + typedef void (*ConnectionEventCallback_t)(const ConnectionCallbackParams_t *params); + typedef void (*DisconnectionEventCallback_t)(const DisconnectionCallbackParams_t *params); typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t; /* @@ -898,13 +893,7 @@ * Set up a callback for timeout events. Refer to TimeoutSource_t for * possible event types. */ - void onTimeout(TimeoutEventCallback_t callback) { - timeoutCallbackChain.add(callback); - } - - TimeoutEventCallbackChain_t& onTimeout() { - return timeoutCallbackChain; - } + void onTimeout(TimeoutEventCallback_t callback) {timeoutCallback = callback;} /** * Append to a chain of callbacks to be invoked upon GAP connection. @@ -914,10 +903,6 @@ 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. */ @@ -926,10 +911,6 @@ template<typename T> void onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t*)) {disconnectionCallChain.add(tptr, mptr);} - DisconnectionEventCallbackChain_t& onDisconnection() { - return disconnectionCallChain; - } - /** * Set the application callback for radio-notification events. * @@ -959,14 +940,11 @@ */ void onRadioNotification(void (*callback)(bool param)) { radioNotificationCallback.attach(callback); - // why does it start radio notification ? It is not even indicated in the - // doc that it start the listening process initRadioNotification(); } template <typename T> void onRadioNotification(T *tptr, void (T::*mptr)(bool)) { radioNotificationCallback.attach(tptr, mptr); - // why does it start radio notification ? initRadioNotification(); } @@ -978,7 +956,7 @@ _scanResponse(), state(), scanningActive(false), - timeoutCallbackChain(), + timeoutCallback(NULL), radioNotificationCallback(), onAdvertisementReport(), connectionCallChain(), @@ -1024,8 +1002,8 @@ } void processTimeoutEvent(TimeoutSource_t source) { - if (timeoutCallbackChain) { - timeoutCallbackChain(source); + if (timeoutCallback) { + timeoutCallback(source); } } @@ -1039,11 +1017,11 @@ bool scanningActive; protected: - TimeoutEventCallbackChain_t timeoutCallbackChain; - RadioNotificationEventCallback_t radioNotificationCallback; - AdvertisementReportCallback_t onAdvertisementReport; - ConnectionEventCallbackChain_t connectionCallChain; - DisconnectionEventCallbackChain_t disconnectionCallChain; + TimeoutEventCallback_t timeoutCallback; + RadioNotificationEventCallback_t radioNotificationCallback; + AdvertisementReportCallback_t onAdvertisementReport; + CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t*> connectionCallChain; + CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> disconnectionCallChain; private: /* Disallow copy and assignment. */