• 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 :)

    bool shouldDisableBLE() {
      JsfFileHeader header;
      uint32_t addr = jsfFindFile(jsfNameFromString(".ble-dis"­), &header);
      if (!addr) return false; // no file - default
      char isOn;
      jshFlashRead(&isOn, addr, 1);
      return isOn;
    }
    

    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/sear­ch/?q=%23ifdef) NRF52
      return true;
    [#elif](https://forum.espruino.com/searc­h/?q=%23elif) defined(ESP32)
      if (active) {
       return true;
      } else {
       jsExceptionHere(JSET_ERROR,"BLE has been disabled");
       return false;
      }
    [#else](https://forum.espruino.com/searc­h/?q=%23else)
      jsExceptionHere(JSET_ERROR,"BLE not implemented");
      return false;
    [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
    }
    

    Is there an option to use of HWReset ?

    http://www.espruino.com/Reference#l_ESP3­2_reboot ?

    what should be default setting, with or without BLE ?

    I'd say with BLE. We have the feature, so most people will want to be able to 'just use' it.

About

Avatar for Gordon @Gordon started