You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not having much luck getting session save/restore to work.
Multiple examples show that you need to implement NetSaveSessionInfo/NetSaveSessionState/NetGetSessionState.
Based on issue #165 I also added GetAbpProvisioningInfo. When that wasn't actually being called I overrode GetProvisioningStyle to check for a saved session and return ProvisioningStyle::kABP.
At the moment I am using EEPROM as a placeholder. I know it will have endurance problems and once I get it working will switch to storing it in sram on a 2nd mcu acting as an i2c slave (that also acts as a watchdog).
The SessionState gets stored starting at EEPROM address 0. The SessionInfo gets stored starting at EEPROM address sizeof(SessionState):
while I still can't get the convoluted NetGetSessionState flow to work, the underlying arduino-lmic library has a far simpler to use set of functions that work fine.
The following example code works (and will wear out eeprom if used as below)
and then in onEvent:
case EV_JOINED:
...
store_joininfo(netid,devaddr,nwkKey,artKey);
case EV_TXCOMPLETE:
...
uint32_t su = LMIC_getSeqnoUp();
uint8_t *sup = (uint8_t*)&su;
EEPROM.write(0,sup[0]);
EEPROM.write(1,sup[1]);
EEPROM.write(2,sup[2]);
EEPROM.write(3,sup[3]);
EEPROM.commit();
and finally call eep_rejoin(); at startup.
Also, the state this way is 44 bytes instead of far more.
I'm not having much luck getting session save/restore to work.
Multiple examples show that you need to implement NetSaveSessionInfo/NetSaveSessionState/NetGetSessionState.
Based on issue #165 I also added GetAbpProvisioningInfo. When that wasn't actually being called I overrode GetProvisioningStyle to check for a saved session and return ProvisioningStyle::kABP.
At the moment I am using EEPROM as a placeholder. I know it will have endurance problems and once I get it working will switch to storing it in sram on a 2nd mcu acting as an i2c slave (that also acts as a watchdog).
The SessionState gets stored starting at EEPROM address 0. The SessionInfo gets stored starting at EEPROM address sizeof(SessionState):
Here is the output from the first boot with the EEPROM cleared:
Here is the reboot,
You can see it does a rejoin and gets a new AppSKey/NwkSKey
What am I doing wrong? Any chance a fixed version of this could be added as an example?
The text was updated successfully, but these errors were encountered: