@@ -54,36 +54,44 @@ class Gap
54
54
unsigned connected : 1 ; /* *< peripheral is connected to a central */
55
55
} GapState_t;
56
56
57
- /* Event callback handlers */
58
57
typedef void (*EventCallback_t)(void );
58
+ typedef uint16_t Handle_t;
59
+ typedef void (*HandleSpecificEventCallback_t)(Handle_t);
60
+
61
+ /* Event callback handlers */
59
62
void setOnTimeout (EventCallback_t callback) {
60
63
onTimeout = callback;
61
64
}
62
- void setOnConnection (EventCallback_t callback) {
65
+ void setOnConnection (HandleSpecificEventCallback_t callback) {
63
66
onConnection = callback;
64
67
}
65
- void setOnDisconnection (EventCallback_t callback) {
68
+ void setOnDisconnection (HandleSpecificEventCallback_t callback) {
66
69
onDisconnection = callback;
67
70
}
68
71
69
- void handleEvent (GapEvents::gapEvent_e type) {
72
+ void processHandleSpecificEvent (GapEvents::gapEvent_e type, Handle_t handle ) {
70
73
switch (type) {
71
- case GapEvents::GAP_EVENT_TIMEOUT:
72
- state.advertising = 0 ;
73
- if (onTimeout) {
74
- onTimeout ();
75
- }
76
- break ;
77
74
case GapEvents::GAP_EVENT_CONNECTED:
78
75
state.connected = 1 ;
79
76
if (onConnection) {
80
- onConnection ();
77
+ onConnection (handle );
81
78
}
82
79
break ;
83
80
case GapEvents::GAP_EVENT_DISCONNECTED:
84
81
state.connected = 0 ;
85
82
if (onDisconnection) {
86
- onDisconnection ();
83
+ onDisconnection (handle);
84
+ }
85
+ break ;
86
+ }
87
+ }
88
+
89
+ void processEvent (GapEvents::gapEvent_e type) {
90
+ switch (type) {
91
+ case GapEvents::GAP_EVENT_TIMEOUT:
92
+ state.advertising = 0 ;
93
+ if (onTimeout) {
94
+ onTimeout ();
87
95
}
88
96
break ;
89
97
}
@@ -102,9 +110,9 @@ class Gap
102
110
GapState_t state;
103
111
104
112
private:
105
- EventCallback_t onTimeout;
106
- EventCallback_t onConnection;
107
- EventCallback_t onDisconnection;
113
+ EventCallback_t onTimeout;
114
+ HandleSpecificEventCallback_t onConnection;
115
+ HandleSpecificEventCallback_t onDisconnection;
108
116
};
109
117
110
118
#endif // ifndef __GAP_H__
0 commit comments