fix GattServer::onUpdatesDisabled()

This commit is contained in:
Rohit Grover 2015-06-19 08:57:31 +01:00
parent dd7bbc9747
commit 5c2e63a2d8
2 changed files with 24 additions and 13 deletions

View file

@ -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)
{

View file

@ -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<const GattWriteCallbackParams *> dataWrittenCallChain;
CallChainOfFunctionPointersWithContext<const GattReadCallbackParams *> dataReadCallChain;
EventCallback_t updatesEnabledCallback;
EventCallback_t onUpdatesDisabled;
EventCallback_t updatesDisabledCallback;
EventCallback_t onConfirmationReceived;
private: