Skip to content

Commit 3460b48

Browse files
DvdGiessendpgeorge
authored andcommitted
extmod/nimble: Override configuration options set in nimble_port_init.
This moves the runtime initialisation of `ble_hs_cfg` to happen after `nimble_port_init()`. That is consistent with the order used in NimBLE examples. On the ESP32 port this is needed because the ESP-IDF sets up the default RAM secret store callbacks in its implementation of `nimble_port_init()` (specifically, it calls `esp_nimble_init()` which in turn calls `ble_store_ram_init()`). We want to override those with our own callbacks to implement the `IRQ_[GS]ET_SECRET` events in Python. Signed-off-by: Daniël van de Giessen <[email protected]>
1 parent 56f9dcb commit 3460b48

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

extmod/nimble/modbluetooth_nimble.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,6 @@ int mp_bluetooth_init(void) {
592592

593593
mp_bluetooth_nimble_ble_state = MP_BLUETOOTH_NIMBLE_BLE_STATE_STARTING;
594594

595-
ble_hs_cfg.reset_cb = reset_cb;
596-
ble_hs_cfg.sync_cb = sync_cb;
597-
ble_hs_cfg.gatts_register_cb = gatts_register_cb;
598-
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
599-
600-
#if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
601-
ble_hs_cfg.store_read_cb = ble_secret_store_read;
602-
ble_hs_cfg.store_write_cb = ble_secret_store_write;
603-
ble_hs_cfg.store_delete_cb = ble_secret_store_delete;
604-
#endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
605-
606595
MP_STATE_PORT(bluetooth_nimble_root_pointers) = m_new0(mp_bluetooth_nimble_root_pointers_t, 1);
607596
mp_bluetooth_gatts_db_create(&MP_STATE_PORT(bluetooth_nimble_root_pointers)->gatts_db);
608597

@@ -622,6 +611,17 @@ int mp_bluetooth_init(void) {
622611
DEBUG_printf("mp_bluetooth_init: nimble_port_init\n");
623612
nimble_port_init();
624613

614+
ble_hs_cfg.reset_cb = reset_cb;
615+
ble_hs_cfg.sync_cb = sync_cb;
616+
ble_hs_cfg.gatts_register_cb = gatts_register_cb;
617+
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
618+
619+
#if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
620+
ble_hs_cfg.store_read_cb = ble_secret_store_read;
621+
ble_hs_cfg.store_write_cb = ble_secret_store_write;
622+
ble_hs_cfg.store_delete_cb = ble_secret_store_delete;
623+
#endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
624+
625625
// Make sure that the HCI UART and event handling task is running.
626626
mp_bluetooth_nimble_port_start();
627627

0 commit comments

Comments
 (0)