-
So the lines ...
are not needed at all, because there are no events generated.Yes, I think it is there just in case there are more events handled in future but so far there are none other than the flash related ones that will not arrive. Also in your case the
uint8_t sd_enabled; sd_softdevice_is_enabled(&sd_enabled);
could be simplified to have sd_enabled to be 0, so something like
uint8_t sd_enabled=0; [#ifdef](https://forum.espruino.com/search/?q=%23ifdef) BLUETOOTH sd_softdevice_is_enabled(&sd_enabled); [#endif](https://forum.espruino.com/search/?q=%23endif)
could be a better patch handling both cases, but it doesn't matter that much. There is actually slight nuance because there is
sd_softdevice_enable
and alsosd_ble_enable
and you can enable softdevice without enabling BLE so then the sd_softdevice_is_enabled will return true even if BLE is not enabled. But whenBLUETOOTH
library is enabled both are enabled and when disabled both are disabled. But we could in theory have bare softdevice enabled with BLUETOOTH disabled.
Now i understand what is happening. So the lines in
https://github.com/espruino/Espruino/blob/52352efac4f8f40976a4d268a0a074ad15251b29/targets/nrf5x/jshardware.c#L984
are not needed at all, because there are no events generated.
I used your suggested changes from #9 and that works so far for writing to flash.
Thanks again for your help!