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
Revision 369:9a76cc068644, committed 2015-05-08
- Comitter:
- rgrover1
- Date:
- Fri May 08 15:35:48 2015 +0100
- Parent:
- 368:89726b616c1b
- Child:
- 370:678fdba95a62
- Commit message:
- Synchronized with git rev d1bd1a61
Author: Rohit Grover
add support for passkey display.
Changed in this revision
public/BLEDevice.h | Show annotated file Show diff for this revision Revisions of this file |
public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/BLEDevice.h Fri May 08 15:35:48 2015 +0100 +++ b/public/BLEDevice.h Fri May 08 15:35:48 2015 +0100 @@ -509,6 +509,15 @@ void onSecurityContextStored(Gap::HandleSpecificEvent_t callback); /** + * Setup a callback for when the passkey needs to be displayed on a + * peripheral with DISPLAY capability. This happens when security is + * configured to prevent Man-In-The-Middle attacks, and a PIN (or passkey) + * needs to be exchanged between the peers to authenticate the connection + * attempt. + */ + void onPasskeyDisplay(Gap::PasskeyDisplayCallback_t callback); + + /** * Get the security status of a connection. * * @param[in] connectionHandle Handle to identify the connection. @@ -918,4 +927,10 @@ return transport->initializeSecurity(enableBonding, requireMITM, iocaps, passkey); } +inline void +BLEDevice::onPasskeyDisplay(Gap::PasskeyDisplayCallback_t callback) +{ + return transport->getGap().setOnPasskeyDisplay(callback); +} + #endif // ifndef __BLE_DEVICE__ \ No newline at end of file
--- a/public/Gap.h Fri May 08 15:35:48 2015 +0100 +++ b/public/Gap.h Fri May 08 15:35:48 2015 +0100 @@ -139,6 +139,7 @@ typedef void (*SecuritySetupInitiatedCallback_t)(Handle_t, bool allowBonding, bool requireMITM, SecurityIOCapabilities_t iocaps); typedef void (*SecuritySetupCompletedCallback_t)(Handle_t, SecurityCompletionStatus_t status); typedef void (*LinkSecuredCallback_t)(Handle_t handle, SecurityMode_t securityMode); + typedef void (*PasskeyDisplayCallback_t)(Handle_t handle, const Passkey_t passkey); friend class BLEDevice; private: @@ -207,6 +208,11 @@ virtual void setOnSecurityContextStored(HandleSpecificEvent_t callback) {onSecurityContextStored = callback;} /** + * To set the callback for when the passkey needs to be displayed on a peripheral with DISPLAY capability. + */ + virtual void setOnPasskeyDisplay(PasskeyDisplayCallback_t callback) {onPasskeyDisplay = 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. @@ -237,6 +243,7 @@ onSecuritySetupCompleted(), onLinkSecured(), onSecurityContextStored(), + onPasskeyDisplay(), disconnectionCallChain() { /* empty */ } @@ -281,6 +288,12 @@ } } + void processPasskeyDisplayEvent(Handle_t handle, const Passkey_t passkey) { + if (onPasskeyDisplay) { + onPasskeyDisplay(handle, passkey); + } + } + void processEvent(GapEvents::gapEvent_e type) { switch (type) { case GapEvents::GAP_EVENT_TIMEOUT: @@ -306,6 +319,7 @@ SecuritySetupCompletedCallback_t onSecuritySetupCompleted; LinkSecuredCallback_t onLinkSecured; HandleSpecificEvent_t onSecurityContextStored; + PasskeyDisplayCallback_t onPasskeyDisplay; CallChain disconnectionCallChain; private: