• Hi - is it the full reboot you're worried about? Rather than just the change in apps?

    The full reboot is actually handled by the watchdog timer, which I believe is set up in https://github.com/espruino/Espruino/blo­b/912aecb676c78e8fc0282775b46c7ad48c428a­30/targets/nrf5x_dfu/main.c#L207

    When you hold the button, it stops kicking the watchdog and then eventually the watchdog times out and reboots the device.

    As far as I know once it's set you're stuck with it until the next reboot, so you would have to update the bootloader to fix it.

    ... or you could modify the Bangle.js code to just kick the watchdog for longer after the button is pressed (but you run the risk that if that code were to break, you would be unable to hard-reboot the bangle)

  • or you could modify the Bangle.js code to just kick the watchdog for longer after the button is pressed (but you run the risk that if that code were to break, you would be unable to hard-reboot the bangle)

    if you would schedule one timeout at button press to kick once after e.g. 4 seconds it could work to increase to 5+4 seconds and could be safer than setInterval or some random kicking, something like this (just remove print parts)

    var wdTm;
    setWatch(function(e) {
      if (wdTm) {clearTimeout(wdTm);wdTm=0;print("WD kick cleared");}
      if (e.state){
      wdTm = setTimeout(()=>{E.kickWatchdog();wdTm=0;­print("WD kicked");},4000);
      print("BTN Pressed");
      }
    }, BTN, {edge:"both", debounce:50, repeat:true});
    

    however I am not sure how this works when apps are started/killed and where this piece of code should be to work all the time

About

Avatar for Gordon @Gordon started