Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Diff: hw/Gap.h
- Revision:
- 104:6ef5abef5714
- Parent:
- 77:1436ecf09583
- Child:
- 105:f29ab9f74d7e
--- a/hw/Gap.h Wed Jul 09 09:08:53 2014 +0100
+++ b/hw/Gap.h Thu Jul 10 12:12:06 2014 +0100
@@ -54,19 +54,39 @@
unsigned connected : 1; /**< peripheral is connected to a central */
} GapState_t;
+ typedef void (*EventCallback_t)(void);
+ typedef uint16_t Handle_t;
+ typedef void (*HandleSpecificEventCallback_t)(Handle_t);
+
/* Event callback handlers */
- typedef void (*EventCallback_t)(void);
void setOnTimeout(EventCallback_t callback) {
onTimeout = callback;
}
- void setOnConnection(EventCallback_t callback) {
+ void setOnConnection(HandleSpecificEventCallback_t callback) {
onConnection = callback;
}
- void setOnDisconnection(EventCallback_t callback) {
+ void setOnDisconnection(HandleSpecificEventCallback_t callback) {
onDisconnection = callback;
}
- void handleEvent(GapEvents::gapEvent_e type) {
+ void processHandleSpecificEvent(GapEvents::gapEvent_e type, Handle_t handle) {
+ switch (type) {
+ case GapEvents::GAP_EVENT_CONNECTED:
+ state.connected = 1;
+ if (onConnection) {
+ onConnection(handle);
+ }
+ break;
+ case GapEvents::GAP_EVENT_DISCONNECTED:
+ state.connected = 0;
+ if (onDisconnection) {
+ onDisconnection(handle);
+ }
+ break;
+ }
+ }
+
+ void processEvent(GapEvents::gapEvent_e type) {
switch (type) {
case GapEvents::GAP_EVENT_TIMEOUT:
state.advertising = 0;
@@ -74,18 +94,6 @@
onTimeout();
}
break;
- case GapEvents::GAP_EVENT_CONNECTED:
- state.connected = 1;
- if (onConnection) {
- onConnection();
- }
- break;
- case GapEvents::GAP_EVENT_DISCONNECTED:
- state.connected = 0;
- if (onDisconnection) {
- onDisconnection();
- }
- break;
}
}
@@ -102,9 +110,9 @@
GapState_t state;
private:
- EventCallback_t onTimeout;
- EventCallback_t onConnection;
- EventCallback_t onDisconnection;
+ EventCallback_t onTimeout;
+ HandleSpecificEventCallback_t onConnection;
+ HandleSpecificEventCallback_t onDisconnection;
};
#endif // ifndef __GAP_H__
