Hey! I've been working on triggering DFU from within my application. It's obvious that the bootloader in the new SDK has been written to support this but I had some problems getting it working.
The call to ble_stack_init(bool init_softdevice) takes an argument, init_softdevice, which is set to false when DFU has been triggered from within the application. It's used to determine whether or not to call the function sd_mbr_command(). If DFU mode was triggered from within the application, this function does not got called.
The issue I had was this: if I did not call this function, the bootloader would not run. I had to modify the code so it always got called for the device to start advertising in DFU mode.
This works when init_softdefice is false
//if (init_softdevice)
//{
err_code = sd_mbr_command(&com);
APP_ERROR_CHECK(err_code);
//}
This doesn't
if (init_softdevice)
{
err_code = sd_mbr_command(&com);
APP_ERROR_CHECK(err_code);
}
I wouldn't really call this a problem, I've got my system working, but I am confused about why Nordic wrote code that appears to be broken. Am I doing something fundamentally flawed here or was that a bug?