High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Revision 99:58c47085e816, committed 2014-07-03
- Comitter:
- Rohit Grover
- Date:
- Thu Jul 03 09:59:53 2014 +0100
- Parent:
- 98:d751acb2543f
- Child:
- 100:1e80e8032c13
- Commit message:
- switch onDataSent() to become independent of attribute handle
Changed in this revision
hw/BLEDevice.h | Show annotated file Show diff for this revision Revisions of this file |
hw/GattServer.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/hw/BLEDevice.h Thu Jul 03 09:57:05 2014 +0100 +++ b/hw/BLEDevice.h Thu Jul 03 09:59:53 2014 +0100 @@ -201,7 +201,7 @@ /** * 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 @@ } inline void -BLEDevice::onDataSent(GattServer::EventCallback_t callback) +BLEDevice::onDataSent(GattServer::ServerEventCallback_t callback) { transport->getGattServer().setOnDataSent(callback); }
--- a/hw/GattServer.h Thu Jul 03 09:57:05 2014 +0100 +++ b/hw/GattServer.h Thu Jul 03 09:59:53 2014 +0100 @@ -44,7 +44,8 @@ /* 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 @@ 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 @@ } } + 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 @@ 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__