From 5c2e63a2d8ebaf1c076141638542afdf71445f5d Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Fri, 19 Jun 2015 08:57:31 +0100 Subject: [PATCH] fix GattServer::onUpdatesDisabled() --- public/BLE.h | 20 +++++++++++++------- public/GattServer.h | 17 +++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/public/BLE.h b/public/BLE.h index d997193..4680ce2 100644 --- a/public/BLE.h +++ b/public/BLE.h @@ -1215,7 +1215,19 @@ public: gattServer().onUpdatesEnabled(callback); } - void onUpdatesDisabled(GattServer::EventCallback_t callback); + /** + * Setup a callback for when notifications/indications are disabled for a + * characteristic on the local GattServer. + * + * @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.onUpdatesEnabled(...) should be replaced with + * ble.gattServer().onUpdatesEnabled(...). + */ + void onUpdatesDisabled(GattServer::EventCallback_t callback) { + gattServer().onUpdatesDisabled(callback); + } + void onConfirmationReceived(GattServer::EventCallback_t callback); /** @@ -1310,12 +1322,6 @@ typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake o /* BLE methods. Most of these simply forward the calls to the underlying * transport.*/ -inline void -BLE::onUpdatesDisabled(GattServer::EventCallback_t callback) -{ - transport->getGattServer().setOnUpdatesDisabled(callback); -} - inline void BLE::onConfirmationReceived(GattServer::EventCallback_t callback) { diff --git a/public/GattServer.h b/public/GattServer.h index d1f8103..a359ae6 100644 --- a/public/GattServer.h +++ b/public/GattServer.h @@ -38,7 +38,7 @@ protected: dataWrittenCallChain(), dataReadCallChain(), updatesEnabledCallback(NULL), - onUpdatesDisabled(NULL), + updatesDisabledCallback(NULL), onConfirmationReceived(NULL) { /* empty */ } @@ -230,9 +230,14 @@ public: * Setup a callback for when notifications/indications are enabled for a * characteristic on the local GattServer. */ - void onUpdatesEnabled(EventCallback_t callback) {updatesEnabledCallback = callback;} + void onUpdatesEnabled(EventCallback_t callback) {updatesEnabledCallback = callback;} + + /** + * Setup a callback for when notifications/indications are disabled for a + * characteristic on the local GattServer. + */ + void onUpdatesDisabled(EventCallback_t callback) {updatesDisabledCallback = callback;} - void setOnUpdatesDisabled(EventCallback_t callback) {onUpdatesDisabled = callback;} void setOnConfirmationReceived(EventCallback_t callback) {onConfirmationReceived = callback;} protected: @@ -256,8 +261,8 @@ protected: } break; case GattServerEvents::GATT_EVENT_UPDATES_DISABLED: - if (onUpdatesDisabled) { - onUpdatesDisabled(charHandle); + if (updatesDisabledCallback) { + updatesDisabledCallback(charHandle); } break; case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED: @@ -285,7 +290,7 @@ private: CallChainOfFunctionPointersWithContext dataWrittenCallChain; CallChainOfFunctionPointersWithContext dataReadCallChain; EventCallback_t updatesEnabledCallback; - EventCallback_t onUpdatesDisabled; + EventCallback_t updatesDisabledCallback; EventCallback_t onConfirmationReceived; private: