Bangle.js 2: Control length of button press before reboot #5292
Replies: 1 comment
-
Posted at 2022-09-21 by @gfwilliams 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/blob/912aecb676c78e8fc0282775b46c7ad48c428a30/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) Posted at 2022-09-21 by @fanoush
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
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 Posted at 2022-09-21 by AskHolme Perfect this is what i was looking for For me it seems best to simply update the bootloader to have a higher timeout on the watchdog. I will also do some work on a custom clock that locksdown the app code side, but that seems easier for me. My real problem was getting my head around the bootloader/firmware code. Thanks for guiding me in the right direction Posted at 2022-09-21 by @fanoush
Yes. It is just that replacing bootloader is not trivial and is a bit risky without having SWD debugger but yes this is the most sensible solution. Once the watchdog is started the interval BTW the code kicking watchdog is here Posted at 2022-09-23 by @gfwilliams
That's a really neat fix! That would make a nice app. To handle the app reload case I guess all you need is in the boot code you do another Posted at 2022-10-02 by AskHolme Hi So i tried this as i after thinking found it quite neat. As i wanted to kick the watchdog several times i tried something a little more elaborate - as you can see below. Key problem is that it does not work. Initially i set the interval to 3000 miliseconds and it would never get called. Now it is at 500 and it get's called and kicks the watchdog twice. I also tested directly with your code example and it has the same problem. The function set in setTimeout never gets called. I have nothing but a blank v15 firmware running on the watch (i have uploaded an additional app, but this happens on the standard clock without my app have ever been opened)
Posted at 2022-10-03 by @gfwilliams
Ahh - yes, this is the app reload code. The button does two things:
The code will stop the ~10 second timer from happening, but not the 2 sec one. So the watch will still reload the default clock face which will then stop your code from running. If your code was 'boot code' then it would run even after the reload. So for example if you write Posted at 2022-10-03 by AskHolme So i should have written this but i actually started trying with it as boot code, but that did not work at all. I can call setWatch in the boot file, but the watch function never gets activated. Can there be somewhere in the initializing code which clears all watches and which could run after my boot code? Also the reload of the default clock face in 2 secs, where is that controlled as i might want to tingle with that as well Posted at 2022-10-12 by @gfwilliams
The issue could be that the button is already pressed when the Bangle reboots? So you don't get a watch event because there was no state change. Instead you might also want a Posted at 2022-10-12 by @gfwilliams
That one is in Posted at 2022-10-13 by @gfwilliams Ok, I've just added So do:
with cutting edge firmwares and you're sorted Posted at 2022-10-17 by AskHolme Thanks. What constitues a cutting edge firmware? In terms of the other things i cut down my code to below and put in in timer.boot.js and now it "works" meaning that if i boot my bangle then the code will push the reboot down the line as long as i have not done anything but stay on the default clock. But if i boot the bangle, enter the launcher, go back to the default clock or boot the bangle and use the ~2 sec button push to reload the clock then the code will not work.
Posted at 2022-10-18 by @gfwilliams
You can see them listed at https://www.espruino.com/Download#banglejs2 - it's what gets built from the absolute latest code on GitHub.
No - the boot code should always get loaded unless you do the very specific https://www.espruino.com/Bangle.js2#resetting-without-loading-any-code |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-09-14 by AskHolme
Hi.
I am trying to fiddle proof a bangle.Js 2 as i want to use it for various reminders for my 4 year old.
As part of that i would really like to control for how long a interval one must hold the button before a reboot is triggered as the default one seems quite low for my situation.
I have however some difficulties locating the actual code triggering the reboot.
I can locate the firmware code in https://github.com/espruino/Espruino/blob/912aecb676c78e8fc0282775b46c7ad48c428a30/targets/nrf5x_dfu/main.c where nrf_dfu_enter_check seems to be running directly after the reboot (controlling if we boot without loading code etc.)
But what i need is really the trigger for the reboot. I have also looked in the bangle JS code but to no avail. There seems to be a E.Reboot function which trigges the reboot, but i fail to see anythign calling that.
Can someone help on where the trigger code for a reboot is?
Beta Was this translation helpful? Give feedback.
All reactions