• Hi - that's what you'd expect - so what happens is dump() tries to recreate the current state of the interpreter as code. Because onInit has already run, the watch was added already so it creates code for it.

    So that all looks good. What happens if you're connected via Bluetooth when the LED flashes? Do you get any error messages? You could try putting digitalPulse before update to see if that helps - because if update created an error then execution would stop before it got run.

    ... or maybe:

        setWatch(function (e) {
            try {
              update()
              digitalPulse(LED2, 1, 1) // Show activity
            } catch (e) {
              digitalPulse(LED1, 1, 1) // Show activity
              console.log(e);
            }
        }, D2, { repeat: true, edge: 'falling' })
    

    That'll flash green if it's ok, red if there was an error.

    Could you check E.getBatteryPercentage()? It just might be your battery is on the way out?

    gattserverdisconnected usually happens either if the Puck forces a disconnect (which you're not doing) or if it reboots.

  • I was so sure it was the battery that's the issue as it was working for 4-5 days without issue. Then last night (still with the new battery) it stopped working again.

    So whilst it is broken, when the light on the electric meter flashes, I don't get any light flashing on the Puck (I did implement the try/catch above, but neither the red nor green light flashes). I get no error messages when connected in the IDE. I wondered could it have something to do with the memory slots, but doing process.memory().free showed 2016, which I assume is more than enough.

    Would you happen to have any other ideas what I could try?

  • Sat 2019.08.10

    So that you are not waiting, wondering,

    Did you catch this post?

    Out of office, 9th to 26th Aug


    I'm not able to assist as we don't have that type of meter here in the US. However, have you attempted to go back to the original source that Gordon references in #4 and give that a go?

    Are you able to restart and continue, e.g. this is only a run time issue after a period of time, or are you forced to reboot/re-upload?

    Is it possible there is a counter or something related to the date that reaches an upper limit, then causes an over flow or error? Could placing that section inside a try/catch help in identifying a possible cause to investigate further?

    'but doing process.memory().free showed 2016'

    Plenty.

    'but neither the red nor green light flashes'

    Wow, I would expect one or the other, so it appears that setWatch() is no longer seeing edges. It would appear that function update() is stuck in an endless loop. To check, place another console.log() outside of the try/catch in #9 with an additional counter, then monitor. Will/may take a few days before halting, as you pointed out. Not sure if this would work, but at that point, is it possible to block copy that #9 on the left-hand console side of the WebIDE and see if pulses can then be detected? e.g. Espruino is still running and the issue IS in the update() function.

    Try placing a try/catch block(s) inside the update function to see if errors can be trapped, rather than bubbling up and possibly missed.

    As a last resort, pepper the entire flow with console.log() statements and see which one is last recorded.

About

Avatar for Fisu @Fisu started