switch onDataSent() to become independent of attribute handle
This commit is contained in:
parent
e69eff0a2d
commit
33da94e934
2 changed files with 21 additions and 13 deletions
|
@ -201,7 +201,7 @@ public:
|
|||
/**
|
||||
* Setup a callback for the GATT event DATA_SENT.
|
||||
*/
|
||||
void onDataSent(GattServer::EventCallback_t callback);
|
||||
void onDataSent(GattServer::ServerEventCallback_t callback);
|
||||
|
||||
/**
|
||||
* Setup a callback for when a characteristic has its value updated by a
|
||||
|
@ -415,7 +415,7 @@ BLEDevice::onDisconnection(Gap::EventCallback_t disconnectionCallback)
|
|||
}
|
||||
|
||||
inline void
|
||||
BLEDevice::onDataSent(GattServer::EventCallback_t callback)
|
||||
BLEDevice::onDataSent(GattServer::ServerEventCallback_t callback)
|
||||
{
|
||||
transport->getGattServer().setOnDataSent(callback);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ public:
|
|||
|
||||
/* Event callback handlers. */
|
||||
typedef void (*EventCallback_t)(uint16_t attributeHandle);
|
||||
void setOnDataSent(EventCallback_t callback) {
|
||||
typedef void (*ServerEventCallback_t)(void); /* independent of any particular attribute */
|
||||
void setOnDataSent(ServerEventCallback_t callback) {
|
||||
onDataSent = callback;
|
||||
}
|
||||
void setOnDataWritten(EventCallback_t callback) {
|
||||
|
@ -62,11 +63,6 @@ public:
|
|||
|
||||
void handleEvent(GattServerEvents::gattEvent_e type, uint16_t charHandle) {
|
||||
switch (type) {
|
||||
case GattServerEvents::GATT_EVENT_DATA_SENT:
|
||||
if (onDataSent) {
|
||||
onDataSent(charHandle);
|
||||
}
|
||||
break;
|
||||
case GattServerEvents::GATT_EVENT_DATA_WRITTEN:
|
||||
if (onDataWritten) {
|
||||
onDataWritten(charHandle);
|
||||
|
@ -90,6 +86,18 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void handleEvent(GattServerEvents::gattEvent_e type) {
|
||||
switch (type) {
|
||||
case GattServerEvents::GATT_EVENT_DATA_SENT:
|
||||
if (onDataSent) {
|
||||
onDataSent();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
GattServer() : serviceCount(0), characteristicCount(0), onDataSent(NULL), onDataWritten(NULL), onUpdatesEnabled(NULL), onUpdatesDisabled(NULL), onConfirmationReceived(NULL) {
|
||||
/* empty */
|
||||
|
@ -100,11 +108,11 @@ protected:
|
|||
uint8_t characteristicCount;
|
||||
|
||||
private:
|
||||
EventCallback_t onDataSent;
|
||||
EventCallback_t onDataWritten;
|
||||
EventCallback_t onUpdatesEnabled;
|
||||
EventCallback_t onUpdatesDisabled;
|
||||
EventCallback_t onConfirmationReceived;
|
||||
ServerEventCallback_t onDataSent;
|
||||
EventCallback_t onDataWritten;
|
||||
EventCallback_t onUpdatesEnabled;
|
||||
EventCallback_t onUpdatesDisabled;
|
||||
EventCallback_t onConfirmationReceived;
|
||||
};
|
||||
|
||||
#endif // ifndef __GATT_SERVER_H__
|
||||
|
|
Loading…
Reference in a new issue