Have a catch-22 here.
Here is my code:
sd_softdevice_is_enabled(&enabled); // Don't do this if disabled, for example when writing flash at the end if (enabled != 1) { bsp_board_led_on(ERROR_LED); result = nrf_sdh_enable_request(); if (result != NRF_SUCCESS) { NRF_LOG_ERROR("Re-enabling the soft device failed with code %u", result); NRF_LOG_DEBUG("Restarting application"); while(NRF_LOG_PROCESS()); NVIC_SystemReset(); return; } NRF_LOG_DEBUG("No reset was done! Now what?"); }
When I call nrf_sdh_enable_request() it returns the error '0x08 which is SoftDevice already enabled according to the documentation. Now I have disabled softdevice to do a flash write.
THe code may seem a little funky but I am dealing with another problem - on the DK the NVIC_SystemReset(); works but when running on the nRF52840 dongle it does not. So I am trying to work around the bug by re-enabling softdevice and restarting advertising. But that's another one of several issues I am having. Now this one.
Is the error message bad and it is really something else?
NOTE READERS LOOKING AT THIS PROBLEM. The problems I was having ended up being due to the flash write on the dongle versus the DK. That is what made it look like the reset was not working on the dongle. SO I was diving into work a rounds for that. It led to a great number of red herrings. If you follow through this thread it ends up finally focusing on the flash write - not the issue in the title. Some of the other issues raised here are not answered as they were no longer pursued.