LoRa NVRAM clear on restore issues
I had a couple of LoPys on which I had to change batteries today (batteries fully exhausted).
The initial idea was to replace the battery and have the LoPys start again as if they had woken up from sleep. However that did not work, and I ended up having to re-join.
My guess (don't have detailed logs for that though) is that there could be an issue with the recent logic on
lora.nvram_restorewhich clears the NVRAM after the restore. This probably leads to situations that go like this:
- battery is close to exhausted
- LoPy still able to wake up
- starts, nvram_restores, attempts to send
- fully exhausts battery and stops before (or during) nvram_restore
The result is that when a new battery is inserted, it won't be able to nvram_restore.
I'm not sure what the consequences would be if we just kept the previous state and sent a new frame with the same counter (would just the "duplicate" packet be ignored, or would that trigger other issues?).
The alternative (which I'm going to implement for now) will be to re-join automatically if needed (join was done manually when setting up the device only until now), but that seems a bit overkill.
For reference, this is running 1.16.0.b1.