Hello,
I find that after I DFU a new application (using the nRF Connect Mobile App), my device boots into that new application and reconnects to the App, as expected. Then, weirdly, I find that if I disconnect from the app, my device does not start advertising again until after a reboot.
I traced this down to the fact that the ble_advertising module initializes a variable called `current_slave_link_conn_handle` to `BLE_CONN_HANDLE_INVALID` (occurs inside `ble_advertising_init`). If a connection forms before the module is initialized, that variable will get overwritten during initialization, losing the conn handle. Then, when `on_disconnected` is called, it checks that variable before restarting advertising, but since it has been overwritten during initialization, advertising never restarts. I find this happens very consistently for me when the App is trying to reconnect following a successful DFU.
I ultimately resolved the issue by moving the initializing of `current_slave_link_conn_handle` to the `BLE_ADVERTISING_DEF` macro definition in ble_advertising.h. This ensures that member is initialized at compile-time rather than run-time.
The most confusing part of all this is that I don't use `NRF_SDH_DISPATCH_MODEL_INTERRUPT` as my `NRF_SDH_DISPATCH_MODEL`, I use `NRF_SDH_DISPATCH_MODEL_POLLING`, and importantly, I don't call `nrf_sdh_evts_poll` until after I initialize the ble_advertising module. So I don't fully understand how `on_connected` is called to set `current_slave_link_conn_handle` before the ble_advertising module is initialized. Am I missing something here?
I don't know what I'm looking for here... maybe just help someone who's running into the same issue.
Thanks,
Michael
P.S. some more information about my setup:
- nRF52840
- SDK v15.2.0
- FreeRTOS