fix GattServer::onConfirmationReceived()

This commit is contained in:
Rohit Grover 2015-06-19 09:04:33 +01:00
parent 27a32c92a4
commit 16658a5f7f
2 changed files with 21 additions and 15 deletions

View file

@ -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__

View file

@ -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<const GattReadCallbackParams *> dataReadCallChain;
EventCallback_t updatesEnabledCallback;
EventCallback_t updatesDisabledCallback;
EventCallback_t onConfirmationReceived;
EventCallback_t confirmationReceivedCallback;
private:
/* disallow copy and assignment */