From 16658a5f7f42670d1aae709091f564e8b039169a Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Fri, 19 Jun 2015 09:04:33 +0100 Subject: [PATCH] fix GattServer::onConfirmationReceived() --- public/BLE.h | 22 ++++++++++++---------- public/GattServer.h | 14 +++++++++----- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/public/BLE.h b/public/BLE.h index 9398866..2a9de3f 100644 --- a/public/BLE.h +++ b/public/BLE.h @@ -1228,7 +1228,18 @@ public: gattServer().onUpdatesDisabled(callback); } - void onConfirmationReceived(GattServer::EventCallback_t callback); + /** + * Setup a callback for when the GATT server receives a response for an + * indication event sent previously. + * + * @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.onConfirmationReceived(callback) should be replaced with + * ble.gattServer().onConfirmationReceived(callback). + */ + void onConfirmationReceived(GattServer::EventCallback_t callback) { + gattServer().onConfirmationReceived(callback); + } /** * Setup a callback for when the security setup procedure (key generation @@ -1319,13 +1330,4 @@ private: typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake of compatibility with older * code. Will be dropped at some point soon.*/ -/* BLE methods. Most of these simply forward the calls to the underlying - * transport.*/ - -inline void -BLE::onConfirmationReceived(GattServer::EventCallback_t callback) -{ - transport->getGattServer().setOnConfirmationReceived(callback); -} - #endif // ifndef __BLE_H__ diff --git a/public/GattServer.h b/public/GattServer.h index a359ae6..462389e 100644 --- a/public/GattServer.h +++ b/public/GattServer.h @@ -39,7 +39,7 @@ protected: dataReadCallChain(), updatesEnabledCallback(NULL), updatesDisabledCallback(NULL), - onConfirmationReceived(NULL) { + confirmationReceivedCallback(NULL) { /* empty */ } @@ -238,7 +238,11 @@ public: */ void onUpdatesDisabled(EventCallback_t callback) {updatesDisabledCallback = callback;} - void setOnConfirmationReceived(EventCallback_t callback) {onConfirmationReceived = callback;} + /** + * Setup a callback for when the GATT server receives a response for an + * indication event sent previously. + */ + void onConfirmationReceived(EventCallback_t callback) {confirmationReceivedCallback = callback;} protected: void handleDataWrittenEvent(const GattWriteCallbackParams *params) { @@ -266,8 +270,8 @@ protected: } break; case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED: - if (onConfirmationReceived) { - onConfirmationReceived(charHandle); + if (confirmationReceivedCallback) { + confirmationReceivedCallback(charHandle); } break; default: @@ -291,7 +295,7 @@ private: CallChainOfFunctionPointersWithContext dataReadCallChain; EventCallback_t updatesEnabledCallback; EventCallback_t updatesDisabledCallback; - EventCallback_t onConfirmationReceived; + EventCallback_t confirmationReceivedCallback; private: /* disallow copy and assignment */