extmod/nimble: Enable key distribution to support bonding.

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 <daniel@dvdgiessen.nl>
pull/13258/head
Daniël van de Giessen 2023-12-12 15:56:13 +01:00 zatwierdzone przez Damien George
rodzic 3460b48a6d
commit d1e15b9281
1 zmienionych plików z 2 dodań i 0 usunięć

Wyświetl plik

@ -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;