High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Revision 687:85b0a8f457a1, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:53:03 2015 +0100
- Parent:
- 686:1962fb48d9ef
- Child:
- 688:10d28b67a7d5
- Commit message:
- Synchronized with git rev 183665a0
Author: Rohit Grover
setup Gap::onDisconnection
Changed in this revision
public/BLE.h | Show annotated file Show diff for this revision Revisions of this file |
public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/BLE.h Fri Jun 19 15:53:03 2015 +0100 +++ b/public/BLE.h Fri Jun 19 15:53:03 2015 +0100 @@ -1080,16 +1080,30 @@ /** * Used to setup a callback for GAP disconnection. + * + * @note: This API is now *deprecated* and will be dropped in the future. + * You should use the parallel API from GattServer directly. A former call + * to ble.onDisconnection(callback) should be replaced with + * ble.gap().onDisconnection(callback). */ - void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback); + void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { + gap().onDisconnection(disconnectionCallback); + } /** * Append to a chain of callbacks to be invoked upon disconnection; these * callbacks receive no context and are therefore different from the * onDisconnection callback. + * + * @note: This API is now *deprecated* and will be dropped in the future. + * You should use the parallel API from GattServer directly. A former call + * to ble.addToDisconnectionCallchain(...) should be replaced with + * ble.gap().addToDisconnectionCallchain(...). */ template<typename T> - void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)); + void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) { + gap().addToDisconnectionCallChain(tptr, mptr); + } /** * Add a callback for the GATT event DATA_SENT (which is triggered when @@ -1179,18 +1193,6 @@ * transport.*/ inline void -BLE::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) -{ - gap().setOnDisconnection(disconnectionCallback); -} - -template<typename T> -inline void -BLE::addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) { - gap().addToDisconnectionCallChain(tptr, mptr); -} - -inline void BLE::onDataSent(void (*callback)(unsigned count)) { transport->getGattServer().setOnDataSent(callback); }
--- a/public/Gap.h Fri Jun 19 15:53:03 2015 +0100 +++ b/public/Gap.h Fri Jun 19 15:53:03 2015 +0100 @@ -266,7 +266,7 @@ /** * This call initiates the disconnection procedure, and its completion will * be communicated to the application with an invocation of the - * onDisconnection callback. + * disconnectionCallback. * * @param reason * The reason for disconnection to be sent back to the peer. @@ -770,7 +770,17 @@ * @param callback * Pointer to the unique callback. */ - void setOnDisconnection(DisconnectionEventCallback_t callback) {onDisconnection = callback;} + void onDisconnection(DisconnectionEventCallback_t callback) {disconnectionCallback = callback;} + + /** + * Append to a chain of callbacks to be invoked upon disconnection; these + * callbacks receive no context and are therefore different from the + * disconnectionCallback callback. + * @param callback + * function pointer to be invoked upon disconnection; receives no context. + */ + template<typename T> + void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) {disconnectionCallChain.add(tptr, mptr);} /** * Set the application callback for radio-notification events. @@ -807,20 +817,6 @@ */ virtual void setOnPasskeyDisplay(PasskeyDisplayCallback_t callback) {onPasskeyDisplay = callback;} - /** - * Append to a chain of callbacks to be invoked upon disconnection; these - * callbacks receive no context and are therefore different from the - * onDisconnection callback. - * @param callback - * function pointer to be invoked upon disconnection; receives no context. - * - * @note the disconnection CallChain should have been merged with - * onDisconnctionCallback; but this was not possible because - * FunctionPointer (which is a building block for CallChain) doesn't - * accept variadic templates. - */ - template<typename T> - void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) {disconnectionCallChain.add(tptr, mptr);} protected: Gap() : @@ -831,7 +827,7 @@ state(), timeoutCallback(NULL), connectionCallback(NULL), - onDisconnection(NULL), + disconnectionCallback(NULL), onRadioNotification(), onSecuritySetupInitiated(), onSecuritySetupCompleted(), @@ -861,8 +857,8 @@ void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) { state.connected = 0; - if (onDisconnection) { - onDisconnection(handle, reason); + if (disconnectionCallback) { + disconnectionCallback(handle, reason); } disconnectionCallChain.call(); } @@ -930,7 +926,7 @@ protected: TimeoutEventCallback_t timeoutCallback; ConnectionEventCallback_t connectionCallback; - DisconnectionEventCallback_t onDisconnection; + DisconnectionEventCallback_t disconnectionCallback; RadioNotificationEventCallback_t onRadioNotification; SecuritySetupInitiatedCallback_t onSecuritySetupInitiated; SecuritySetupCompletedCallback_t onSecuritySetupCompleted;