SWL2001 icon indicating copy to clipboard operation
SWL2001 copied to clipboard

no reloading context after power on

Open davidBaselga opened this issue 1 year ago • 10 comments

I used LoraWan Basic on stm32Cube with STM32L082KZT6 and semtech SX1276IMLTRT. Join, Uplink and downlink work correctly.

I would like the system not to make a "join" at each startup (power on).

I see backups in EEPROM, at startup during init I also see loading from the EEPROM but I cannot send any frame. I don't understand why and I haven't found an example.

thanks a lot David

davidBaselga avatar Jun 05 '24 12:06 davidBaselga

Hi,

Only Devnonce and joinnonce are stored in non-volatile memory as requested by LoRaWAN standard. The full LoRaWAN stack context is not stored in NVM.

opeyrard avatar Jun 10 '24 13:06 opeyrard

if I understand correctly, To not do a join after a restart I only need joinnonce and Devnonce, or do I need other data?

Thank you very much for your response

davidBaselga avatar Jun 10 '24 16:06 davidBaselga

Hi, In the current LBM implementation, you have to perform a new Join after a Reset. The whole context of LoRaWAN is not saved. We are studying the possibility to improve it (especially to support ABP) in the next release. Many thanks,

opeyrard avatar Jun 25 '24 08:06 opeyrard

Thank you very much for these clarifications.

I succeeded in saving the context by making these modifications in the lower layers:

  • I added the devAdr in the context (CONTEXT_LORAWAN_STACK)
  • I added a function to write to fcnt_up: I have a special algorithm who save de fcnt_up only every 100 to limit writing in eprom
  • on the SMTC_MODEM_EVENT_JOINED event, I added the key backup: smtc_secure_element_store_context(STACK_ID);

So on the reset event:

  • I force the status to join: lorawan_api_set_join_status(STACK_ID, JOINED);
  • I load the modem context: modem_load_modem_context();
  • I load the keys: smtc_secure_element_restore_context(STACK_ID);
  • and I load the new fcnt_up

davidBaselga avatar Jun 25 '24 10:06 davidBaselga

Hi, To be more LoRaWAN compliant, you could improve your code by saving the LoRaWAN/regional parameters (channel, Data rate, RX1 delay ...) sent by the network server. Many thanks,

opeyrard avatar Jul 08 '24 12:07 opeyrard

Hi, it would indeed be very useful to be able to reuse the OTAA context across boot cycles. Any rough estimates on when this feature would be available?

jonaskerremans-rombit avatar Oct 17 '24 15:10 jonaskerremans-rombit

Shouldn't this be implemented specially for devices not powered by battery (like an energy meter)? Resets can be a frequent thing, and It makes no sense to perform a join every time there's a power outage.

gonzabrusco avatar Dec 30 '24 12:12 gonzabrusco

Hi, At this stage, this feature is not part of the roadmap. This is linked to ABP support. This could be implemented in the future, depending on ABP support on LoRaWAN 1.2. Many thanks,

opeyrard avatar Feb 17 '25 14:02 opeyrard

@opeyrard, do you expect a device powered by an unreliable power source, like the electrical grid, to perform the join procedure every time it loses power?

Quoting SEMTECH's own documentation (https://learn.semtech.com/mod/book/view.php?id=171&chapterid=101):

To ensure that a power cycle does not require the device to rejoin, store the AppSKey, NwkSKey, last used DevNonce, and any JoinNonce values in non-volatile memory (NVM). If you use ABP, also store FCntUp in NVM.

gonzabrusco avatar Feb 18 '25 21:02 gonzabrusco

For my project, I have a lot equipment (>50 or 100) that are powered by 220V and start at the same time. If I do the join procedure it takes several hours for all the equipment to connect on network. I implemented random but it is not efficient. The context reload is mandatory for me. Futhermore, in basic source, the context and key are save in EEPROM or Flash, but some data is missing, I don't understand why to save it ?

davidBaselga avatar Feb 19 '25 21:02 davidBaselga