@@ -44,7 +44,8 @@ class GattServer
44
44
45
45
/* Event callback handlers. */
46
46
typedef void (*EventCallback_t)(uint16_t attributeHandle);
47
- void setOnDataSent (EventCallback_t callback) {
47
+ typedef void (*ServerEventCallback_t)(void ); /* independent of any particular attribute */
48
+ void setOnDataSent (ServerEventCallback_t callback) {
48
49
onDataSent = callback;
49
50
}
50
51
void setOnDataWritten (EventCallback_t callback) {
@@ -62,11 +63,6 @@ class GattServer
62
63
63
64
void handleEvent (GattServerEvents::gattEvent_e type, uint16_t charHandle) {
64
65
switch (type) {
65
- case GattServerEvents::GATT_EVENT_DATA_SENT:
66
- if (onDataSent) {
67
- onDataSent (charHandle);
68
- }
69
- break ;
70
66
case GattServerEvents::GATT_EVENT_DATA_WRITTEN:
71
67
if (onDataWritten) {
72
68
onDataWritten (charHandle);
@@ -90,6 +86,18 @@ class GattServer
90
86
}
91
87
}
92
88
89
+ void handleEvent (GattServerEvents::gattEvent_e type) {
90
+ switch (type) {
91
+ case GattServerEvents::GATT_EVENT_DATA_SENT:
92
+ if (onDataSent) {
93
+ onDataSent ();
94
+ }
95
+ break ;
96
+ default :
97
+ break ;
98
+ }
99
+ }
100
+
93
101
protected:
94
102
GattServer () : serviceCount(0 ), characteristicCount(0 ), onDataSent(NULL ), onDataWritten(NULL ), onUpdatesEnabled(NULL ), onUpdatesDisabled(NULL ), onConfirmationReceived(NULL ) {
95
103
/* empty */
@@ -100,11 +108,11 @@ class GattServer
100
108
uint8_t characteristicCount;
101
109
102
110
private:
103
- EventCallback_t onDataSent;
104
- EventCallback_t onDataWritten;
105
- EventCallback_t onUpdatesEnabled;
106
- EventCallback_t onUpdatesDisabled;
107
- EventCallback_t onConfirmationReceived;
111
+ ServerEventCallback_t onDataSent;
112
+ EventCallback_t onDataWritten;
113
+ EventCallback_t onUpdatesEnabled;
114
+ EventCallback_t onUpdatesDisabled;
115
+ EventCallback_t onConfirmationReceived;
108
116
};
109
117
110
118
#endif // ifndef __GATT_SERVER_H__
0 commit comments