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
Revision 357:d4bb5d2b837a, committed 2015-05-08
- Comitter:
- rgrover1
- Date:
- Fri May 08 15:35:47 2015 +0100
- Parent:
- 356:261c251c6936
- Child:
- 358:6a3536a141f3
- Commit message:
- Synchronized with git rev 98814d23
Author: Rohit Grover
update initializeSecurity() to take in args.
Changed in this revision
--- a/common/BLEDeviceInstanceBase.h Fri May 08 15:35:46 2015 +0100
+++ b/common/BLEDeviceInstanceBase.h Fri May 08 15:35:47 2015 +0100
@@ -30,7 +30,10 @@
virtual ble_error_t init(void) = 0;
virtual ble_error_t shutdown(void) = 0;
virtual ble_error_t reset(void) = 0;
- virtual ble_error_t initializeSecurity(void) = 0;
+ virtual ble_error_t initializeSecurity(bool enableBonding = true,
+ bool requireMITM = true,
+ Gap::SecurityIOCapabilities_t iocaps = Gap::IO_CAPS_NONE,
+ const Gap::Passkey_t passkey = NULL) = 0;
virtual ble_error_t setTxPower(int8_t txPower) = 0;
virtual void getPermittedTxPowerValues(const int8_t **, size_t *) = 0;
virtual void waitForEvent(void) = 0;
--- a/public/BLEDevice.h Fri May 08 15:35:46 2015 +0100
+++ b/public/BLEDevice.h Fri May 08 15:35:47 2015 +0100
@@ -496,8 +496,20 @@
* the actual cryptographic algorithms and protocol exchanges that allow two
* devices to securely exchange data and privately detect each other.
* Calling this API is a prerequisite for encryption and pairing (bonding).
+ *
+ * @param[in] enableBonding Allow for bonding.
+ * @param[in] requireMITM Require protection for man-in-the-middle attacks.
+ * @param[in] iocaps To specify IO capabilities of this peripheral,
+ * such as availability of a display or keyboard to
+ * support out-of-band exchanges of security data.
+ * @param[in] passkey To specify a static passkey.
+ *
+ * @return BLE_ERROR_NONE on success.
*/
- ble_error_t initializeSecurity(void);
+ ble_error_t initializeSecurity(bool enableBonding = true,
+ bool requireMITM = true,
+ Gap::SecurityIOCapabilities_t iocaps = Gap::IO_CAPS_NONE,
+ const Gap::Passkey_t passkey = NULL);
public:
BLEDevice() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true) {
@@ -891,9 +903,12 @@
}
inline ble_error_t
-BLEDevice::initializeSecurity(void)
+BLEDevice::initializeSecurity(bool enableBonding,
+ bool requireMITM,
+ Gap::SecurityIOCapabilities_t iocaps,
+ const Gap::Passkey_t passkey)
{
- return transport->initializeSecurity();
+ return transport->initializeSecurity(enableBonding, requireMITM, iocaps, passkey);
}
#endif // ifndef __BLE_DEVICE__
\ No newline at end of file
--- a/public/Gap.h Fri May 08 15:35:46 2015 +0100
+++ b/public/Gap.h Fri May 08 15:35:47 2015 +0100
@@ -75,6 +75,22 @@
ENCRYPTED /**< The link is secure.*/
};
+ enum SecurityIOCapabilities_t {
+ IO_CAPS_DISPLAY_ONLY = 0x00, /**< Display Only. */
+ IO_CAPS_DISPLAY_YESNO = 0x01, /**< Display and Yes/No entry. */
+ IO_CAPS_KEYBOARD_ONLY = 0x02, /**< Keyboard Only. */
+ IO_CAPS_NONE = 0x03, /**< No I/O capabilities. */
+ IO_CAPS_KEYBOARD_DISPLAY = 0x04, /**< Keyboard and Display. */
+ };
+
+ /**
+ * Declaration of type containing a passkey to be used during pairing. This
+ * is passed into initializeSecurity() to specify a pre-programmed passkey
+ * for authentication instead of generating a random one.
+ */
+ static const unsigned PASSKEY_LEN = 6;
+ typedef uint8_t Passkey_t[PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
+
static const uint16_t UNIT_1_25_MS = 1250; /**< Number of microseconds in 1.25 milliseconds. */
static const uint16_t UNIT_0_625_MS = 650; /**< Number of microseconds in 0.625 milliseconds. */
static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis) {
