Dear Nordic experts,
After experiencing a lot of random issues when retaining bond information during a DFU on some mobile devices, we've decided to choose the safest route and remove any bond information prior to performing a DFU. However, this proves to be harder than expected and I'm hoping that one of the Nordic experts here can point me in the right direction. My current process is as follows:
- When a DFU request is received, we remove the bond by calling dm_device_delete_all()
- After the device manager event 'context deleted' is received, we initiate the normal DFU process (bootloader_start in dfu_app_handler.c) which does the following:
...
static void bootloader_start(uint16_t conn_handle){
uint32_t err_code;
m_dfu_process_active = true;
uint16_t sys_serv_attr_len = sizeof(m_peer_data.sys_serv_attr);
err_code = sd_ble_gatts_sys_attr_get(conn_handle,
m_peer_data.sys_serv_attr,
&sys_serv_attr_len,
BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
if (err_code != NRF_SUCCESS)
{
// Any error at this stage means the system service attributes could not be fetched.
// This means the service changed indication cannot be sent in DFU mode, but connection
// is still possible to establish.
}
m_reset_prepare();
err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
APP_ERROR_CHECK(err_code);
err_code = sd_softdevice_disable();
APP_ERROR_CHECK(err_code);
pwm_driver_deinit();
dfu_app_peer_data_set(conn_handle);
NVIC_ClearPendingIRQ(SWI2_IRQn);
interrupts_disable();
#ifdef FREERTOS
__set_CONTROL(0); // switch to MSP
#endif
bootloader_util_app_start(NRF_UICR->NRFFW[0]);
}
The problem is that in this situation, after the switch to the bootloader has been made, the bootloader doesn't want to connect with the DFU process (nrfConnect). So I am assuming that some connection context should be (re)stored after the bond has been removed. I know that the bond removal mechanism works because we use it to remove a bond on the device when the user holds a button for a while, but in that case we disconnect and power down after we receive the dm event.
What is the proper way of doing this?
Thank you in advance!
(Target: NRF52, SDK11.0, bootloader S132 dual bank)