diff options
author | Daniël van de Giessen <daniel@dvdgiessen.nl> | 2023-12-08 18:57:07 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-02-29 14:25:59 +1100 |
commit | 3460b48a6d3af423e8592add99432172523639ba (patch) | |
tree | ce9d50b054665ed9fe6e4ef3ce45740c491d4ced | |
parent | 56f9dcb580a6ee6c10f6db59a72e3b216e4e4dfc (diff) | |
download | micropython-3460b48a6d3af423e8592add99432172523639ba.tar.gz micropython-3460b48a6d3af423e8592add99432172523639ba.zip |
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 <daniel@dvdgiessen.nl>
-rw-r--r-- | extmod/nimble/modbluetooth_nimble.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index c053ac56cf..b4610564cd 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -592,17 +592,6 @@ int mp_bluetooth_init(void) { mp_bluetooth_nimble_ble_state = MP_BLUETOOTH_NIMBLE_BLE_STATE_STARTING; - ble_hs_cfg.reset_cb = reset_cb; - ble_hs_cfg.sync_cb = sync_cb; - ble_hs_cfg.gatts_register_cb = gatts_register_cb; - ble_hs_cfg.store_status_cb = ble_store_util_status_rr; - - #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING - 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; - #endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING - MP_STATE_PORT(bluetooth_nimble_root_pointers) = m_new0(mp_bluetooth_nimble_root_pointers_t, 1); mp_bluetooth_gatts_db_create(&MP_STATE_PORT(bluetooth_nimble_root_pointers)->gatts_db); @@ -622,6 +611,17 @@ int mp_bluetooth_init(void) { DEBUG_printf("mp_bluetooth_init: nimble_port_init\n"); nimble_port_init(); + ble_hs_cfg.reset_cb = reset_cb; + ble_hs_cfg.sync_cb = sync_cb; + ble_hs_cfg.gatts_register_cb = gatts_register_cb; + ble_hs_cfg.store_status_cb = ble_store_util_status_rr; + + #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING + 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; + #endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING + // Make sure that the HCI UART and event handling task is running. mp_bluetooth_nimble_port_start(); |