Should we use partition free, or is there a better place ?
Use a 'file' in require("Storage") - so use jsfFindFile. jsfReadFile would be perfect but you can't use it because you won't have any JsVars available :)
Then require("Storage").write(".ble-dis",[1]) would disable it. That could obviously be wrapped up a bit better though :)
Do we need a message during startup, that BLE is disabled ?
I doubt it. If the flag has been set then people will know. I guess BLE functions may need a check & exception in there to ensure they can't be used if BLE hasn't been enabled?
Is there a way to make NRF, Bluetooth and others inactive, so they cannot be called by accident ?
Not easily. You could add a if (!jsBleActive()) return 0 to every function, and then do:
bool bleActive() {
[#ifdef](https://forum.espruino.com/search/?q=%23ifdef) NRF52
return true;
[#elif](https://forum.espruino.com/search/?q=%23elif) defined(ESP32)
if (active) {
return true;
} else {
jsExceptionHere(JSET_ERROR,"BLE has been disabled");
return false;
}
[#else](https://forum.espruino.com/search/?q=%23else)
jsExceptionHere(JSET_ERROR,"BLE not implemented");
return false;
[#endif](https://forum.espruino.com/search/?q=%23endif)
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Use a 'file' in
require("Storage")
- so usejsfFindFile
.jsfReadFile
would be perfect but you can't use it because you won't have any JsVars available :)Then
require("Storage").write(".ble-dis",[1])
would disable it. That could obviously be wrapped up a bit better though :)I doubt it. If the flag has been set then people will know. I guess BLE functions may need a check & exception in there to ensure they can't be used if BLE hasn't been enabled?
Not easily. You could add a
if (!jsBleActive()) return 0
to every function, and then do:http://www.espruino.com/Reference#l_ESP32_reboot ?
I'd say with BLE. We have the feature, so most people will want to be able to 'just use' it.