mirror of https://github.com/ARMmbed/mbed-os.git
avoid recalculating oob fi already calculating
parent
db20ecbbde
commit
02ba2848a8
|
@ -974,7 +974,8 @@ public:
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate local OOB data to be sent to the application which sends it to the peer.p
|
* Generate local OOB data to be sent to the application which sends it to the peer.
|
||||||
|
* @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure
|
||||||
*/
|
*/
|
||||||
virtual ble_error_t generate_secure_connections_oob() = 0;
|
virtual ble_error_t generate_secure_connections_oob() = 0;
|
||||||
|
|
||||||
|
|
|
@ -510,17 +510,35 @@ ble_error_t GenericSecurityManager::generateOOB(
|
||||||
const address_t *address
|
const address_t *address
|
||||||
) {
|
) {
|
||||||
/* legacy pairing */
|
/* legacy pairing */
|
||||||
_oob_temporary_key_creator_address = *address;
|
ble_error_t status = get_random_data(_oob_temporary_key.buffer(), 16);
|
||||||
get_random_data(_oob_temporary_key.buffer(), 16);
|
|
||||||
|
|
||||||
eventHandler->legacyPairingOobGenerated(
|
if (status == BLE_ERROR_NONE) {
|
||||||
&_oob_temporary_key_creator_address,
|
_oob_temporary_key_creator_address = *address;
|
||||||
&_oob_temporary_key
|
|
||||||
);
|
|
||||||
|
|
||||||
/* secure connections */
|
eventHandler->legacyPairingOobGenerated(
|
||||||
_oob_local_address = *address;
|
&_oob_temporary_key_creator_address,
|
||||||
_pal.generate_secure_connections_oob();
|
&_oob_temporary_key
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Secure connections. Avoid generating if we're already waiting for it.
|
||||||
|
* If a local random is set to 0 it means we're already calculating
|
||||||
|
* unless the address is invalid which means we've never done so yet */
|
||||||
|
if (_oob_local_random != 0 || _oob_local_address == address_t()) {
|
||||||
|
status = _pal.generate_secure_connections_oob();
|
||||||
|
|
||||||
|
if (status == BLE_ERROR_NONE) {
|
||||||
|
_oob_local_address = *address;
|
||||||
|
/* this will be updated when calculation completes */
|
||||||
|
_oob_local_random = 0;
|
||||||
|
} else if (status != BLE_ERROR_NOT_IMPLEMENTED) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BLE_STACK_BUSY;
|
||||||
|
}
|
||||||
|
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue