From d1e15b928107e2459b65c7a2484517e9e2a830cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Tue, 12 Dec 2023 15:56:13 +0100 Subject: [PATCH] extmod/nimble: Enable key distribution to support bonding. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This sets the BLE key distribution parameters at runtime. This isn't needed in most ports since we already set the default values in `extmod/nimble/syscfg/syscfg.h`; however in the ESP32 port that headerfile is not used, and the default values in the ESP-IDF don't enable key distribution nor can we change those defaults via `sdkconfig`. Thus we're setting these values explicitly at runtime. Signed-off-by: Daniƫl van de Giessen --- extmod/nimble/modbluetooth_nimble.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index b4610564cd..5bab43a0cc 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -617,6 +617,8 @@ int mp_bluetooth_init(void) { ble_hs_cfg.store_status_cb = ble_store_util_status_rr; #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING + ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID | BLE_SM_PAIR_KEY_DIST_SIGN; + ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID | BLE_SM_PAIR_KEY_DIST_SIGN; ble_hs_cfg.store_read_cb = ble_secret_store_read; ble_hs_cfg.store_write_cb = ble_secret_store_write; ble_hs_cfg.store_delete_cb = ble_secret_store_delete;