I'm working on a custom board that uses an nRF52832 module. It has a single button that is used to power the device On/Off and a >= 5sec long press from Off to force enter the bootloader (my fail-case backup). The bootloader can also be entered by the buttonless DFU.
I would like to delete bond data when entering the bootloader by the long-press since I cannot provide a separate button for it. I also don't want to use BLE command to do it in case of app failure.
I added a bootloader entry case for the long press in static bool dfu_enter_check(void) in nrf_bootloader.c and I would like to delete bonds here, shown below:
static bool dfu_enter_check(void)
{
// If power button is held for >= 5 seconds, then enter DFU
uint32_t timeout_ticks = nrf_bootloader_dfu_timer_counter_get() + NRF_BOOTLOADER_MS_TO_TICKS(5000);
while (0 == nrf_gpio_pin_read(PIN_PB_OUT))
{
if(nrf_bootloader_dfu_timer_counter_get() >= timeout_ticks)
{
NRF_LOG_DEBUG("DFU mode requested via timed button press.");
delete_bonds(); // <-- This
return true;
}
}
...
return false;
}
My question is, is there a quick and dirty way to do this in the bootloader without having to pull in the entire peer manager?