ArmDeveloperEcosystem / lorawan-library-for-pico

Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040 based board. 📡
BSD 3-Clause "New" or "Revised" License
125 stars 47 forks source link

frame counter lost after power cycle? #42

Closed ioanfesteu closed 7 months ago

ioanfesteu commented 7 months ago

Hi, I would like to ask for help for my problem:

I am running the library without problems but I am at the point I am looking to save battery energy. I managed to put my Pico in deep sleep mode but even in such a state it consumes about 1.8 mA which is way to much. So I was thinking to use an auxiliary mcu such as ATTiny85 to power off my Pico between sensor readings (TinyML stuff) and LoRaWAN sessions then going in deep sleep mode (around 0.0047 mA).

After a power cycle I am not going to join again the network but instead I am invoking only lorawan_init_otaa() then send my payload when ready. Can anybody confirm that thelorawan_init_otaa() is reseting the FCntUp to 0 or they are retrieving the last saved value (if saved)?

Thank you!

ioanfesteu commented 7 months ago

I can confirm that FCntUp is stored. It was my code that messed things. So, if anybody wants to power off the Pico to conserve battery this can be done with an external mcu then at startup only invoke lorawan_init_otaa() , whitout the join steps, and the context will be restored from the nvram.

sandeepmistry commented 7 months ago

@ioanfesteu thanks for the update, can this be closed now?

ioanfesteu commented 7 months ago

@sandeepmistry yes it can be closed, thank you.