Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
Fork of BLE_API by
Diff: public/Gap.h
- Revision:
- 349:b8b2b3973c47
- Parent:
- 346:4a42f777161f
- Child:
- 352:79d7cb60ae27
--- a/public/Gap.h Fri May 08 15:35:45 2015 +0100 +++ b/public/Gap.h Fri May 08 15:35:46 2015 +0100 @@ -81,6 +81,7 @@ addr_type_t peerAddrType, const address_t peerAddr, addr_type_t ownAddrType, const address_t ownAddr, const ConnectionParams_t *); + typedef void (*HandleSpecificEvent_t)(Handle_t handle); typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t); typedef void (*RadioNotificationEventCallback_t) (bool radio_active); /* gets passed true for ACTIVE; false for INACTIVE. */ @@ -125,6 +126,29 @@ virtual void setOnRadioNotification(RadioNotificationEventCallback_t callback) {onRadioNotification = callback;} /** + * To indicate that security procedure for link has started. + */ + virtual void setOnSecuritySetupStarted(HandleSpecificEvent_t callback) {onSecuritySetupStarted = callback;} + + /** + * To indicate that security procedure for link has completed. + */ + virtual void setOnSecuritySetupCompleted(HandleSpecificEvent_t callback) {onSecuritySetupCompleted = callback;} + + /** + * To indicate that link with the peer is secured. For bonded devices, + * subsequent reconnections with bonded peer will result only in this callback + * when the link is secured and setup procedures will not occur unless the + * bonding information is either lost or deleted on either or both sides. + */ + virtual void setOnLinkSecured(HandleSpecificEvent_t callback) {onLinkSecured = callback;} + + /** + * To indicate that device context is stored persistently. + */ + virtual void setOnSecurityContextStored(HandleSpecificEvent_t callback) {onSecurityContextStored = callback;} + + /** * Append to a chain of callbacks to be invoked upon disconnection; these * callbacks receive no context and are therefore different from the * onDisconnection callback. @@ -145,8 +169,17 @@ } protected: - /* Default constructor. */ - Gap() : state(), onTimeout(NULL), onConnection(NULL), onDisconnection(NULL), onRadioNotification(), disconnectionCallChain() { + Gap() : + state(), + onTimeout(NULL), + onConnection(NULL), + onDisconnection(NULL), + onRadioNotification(), + onSecuritySetupStarted(), + onSecuritySetupCompleted(), + onLinkSecured(), + onSecurityContextStored(), + disconnectionCallChain() { /* empty */ } @@ -166,6 +199,30 @@ disconnectionCallChain.call(); } + void processSecuritySetupStartedEvent(Handle_t handle) { + if (onSecuritySetupStarted) { + onSecuritySetupStarted(handle); + } + } + + void processSecuritySetupCompletedEvent(Handle_t handle) { + if (onSecuritySetupCompleted) { + onSecuritySetupCompleted(handle); + } + } + + void processLinkSecuredEvent(Handle_t handle) { + if (onLinkSecured) { + onLinkSecured(handle); + } + } + + void processSecurityContextStoredEvent(Handle_t handle) { + if (onSecurityContextStored) { + onSecurityContextStored(handle); + } + } + void processEvent(GapEvents::gapEvent_e type) { switch (type) { case GapEvents::GAP_EVENT_TIMEOUT: @@ -187,6 +244,10 @@ ConnectionEventCallback_t onConnection; DisconnectionEventCallback_t onDisconnection; RadioNotificationEventCallback_t onRadioNotification; + HandleSpecificEvent_t onSecuritySetupStarted; + HandleSpecificEvent_t onSecuritySetupCompleted; + HandleSpecificEvent_t onLinkSecured; + HandleSpecificEvent_t onSecurityContextStored; CallChain disconnectionCallChain; private: