Skip to content

Commit 1b5e444

Browse files
committed
If privacy is not configured do not share ID keys.
1 parent d21e675 commit 1b5e444

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/NimBLEDevice.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -877,17 +877,21 @@ bool NimBLEDevice::init(const std::string& deviceName) {
877877
nimble_port_init();
878878

879879
// Setup callbacks for host events
880-
ble_hs_cfg.reset_cb = NimBLEDevice::onReset;
881-
ble_hs_cfg.sync_cb = NimBLEDevice::onSync;
880+
ble_hs_cfg.reset_cb = NimBLEDevice::onReset;
881+
ble_hs_cfg.sync_cb = NimBLEDevice::onSync;
882+
ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /*TODO: Implement handler for this*/
882883

883884
// Set initial security capabilities
884885
ble_hs_cfg.sm_io_cap = BLE_HS_IO_NO_INPUT_OUTPUT;
885886
ble_hs_cfg.sm_bonding = 0;
886887
ble_hs_cfg.sm_mitm = 0;
887888
ble_hs_cfg.sm_sc = 1;
888-
ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
889-
ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
890-
ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /*TODO: Implement handler for this*/
889+
ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC;
890+
ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC;
891+
# if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
892+
ble_hs_cfg.sm_our_key_dist |= BLE_SM_PAIR_KEY_DIST_ID;
893+
ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ID;
894+
# endif
891895

892896
setDeviceName(deviceName);
893897
ble_store_config_init();

0 commit comments

Comments
 (0)