summaryrefslogtreecommitdiff
path: root/src/components/ble/NimbleController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ble/NimbleController.cpp')
-rw-r--r--src/components/ble/NimbleController.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 10eb429..a66551e 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -116,25 +116,38 @@ void NimbleController::Init() {
ASSERT(rc == 0);
bleController.Address(std::move(address));
- switch (addrType) {
- case BLE_OWN_ADDR_PUBLIC:
- bleController.AddressType(Ble::AddressTypes::Public);
- break;
- case BLE_OWN_ADDR_RANDOM:
- bleController.AddressType(Ble::AddressTypes::Random);
- break;
- case BLE_OWN_ADDR_RPA_PUBLIC_DEFAULT:
- bleController.AddressType(Ble::AddressTypes::RPA_Public);
- break;
- case BLE_OWN_ADDR_RPA_RANDOM_DEFAULT:
- bleController.AddressType(Ble::AddressTypes::RPA_Random);
- break;
+ if (bleController.isPasskeyEnabled) {
+ switch (addrType) {
+ case BLE_OWN_ADDR_PUBLIC:
+ bleController.AddressType(Ble::AddressTypes::Public);
+ break;
+ case BLE_OWN_ADDR_RANDOM:
+ bleController.AddressType(Ble::AddressTypes::Random);
+ break;
+ case BLE_OWN_ADDR_RPA_PUBLIC_DEFAULT:
+ bleController.AddressType(Ble::AddressTypes::RPA_Public);
+ break;
+ case BLE_OWN_ADDR_RPA_RANDOM_DEFAULT:
+ bleController.AddressType(Ble::AddressTypes::RPA_Random);
+ break;
+ }
+ } else {
+ switch (addrType) {
+ case BLE_OWN_ADDR_PUBLIC:
+ bleController.AddressType(Ble::AddressTypes::Public);
+ break;
+ default:
+ bleController.AddressType(Ble::AddressTypes::Random);
+ break;
+ }
}
rc = ble_gatts_start();
ASSERT(rc == 0);
- RestoreBond();
+ if (bleController.isPasskeyEnabled) {
+ RestoreBond();
+ }
StartAdvertising();
}
@@ -217,7 +230,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
NRF_LOG_INFO("Disconnect event : BLE_GAP_EVENT_DISCONNECT");
NRF_LOG_INFO("disconnect reason=%d", event->disconnect.reason);
- if (event->disconnect.conn.sec_state.bonded) {
+ if (bleController.isPasskeyEnabled && event->disconnect.conn.sec_state.bonded) {
PersistBond(event->disconnect.conn);
}
@@ -252,7 +265,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
NRF_LOG_INFO("Security event : BLE_GAP_EVENT_ENC_CHANGE");
NRF_LOG_INFO("encryption change event; status=%0X ", event->enc_change.status);
- if (event->enc_change.status == 0) {
+ if (bleController.isPasskeyEnabled && event->enc_change.status == 0) {
struct ble_gap_conn_desc desc;
ble_gap_conn_find(event->enc_change.conn_handle, &desc);
if (desc.sec_state.bonded) {
@@ -281,7 +294,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
* Use the tinycrypt prng here since rand() is predictable.
*/
NRF_LOG_INFO("Security event : BLE_GAP_EVENT_PASSKEY_ACTION");
- if (event->passkey.params.action == BLE_SM_IOACT_DISP) {
+ if (bleController.isPasskeyEnabled && event->passkey.params.action == BLE_SM_IOACT_DISP) {
struct ble_sm_io pkey = {0};
pkey.action = event->passkey.params.action;