update initializeSecurity() to take in args.
This commit is contained in:
parent
ecf07db704
commit
98814d23ae
3 changed files with 38 additions and 4 deletions
|
@ -30,7 +30,10 @@ public:
|
|||
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;
|
||||
|
|
|
@ -496,8 +496,20 @@ public:
|
|||
* 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 @@ BLEDevice::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP
|
|||
}
|
||||
|
||||
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__
|
||||
|
|
16
public/Gap.h
16
public/Gap.h
|
@ -75,6 +75,22 @@ public:
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue