LMIC_setSessionState, and is it possible to set the state to avoid a join?

Hi,

I was playing around with trying to avoid a join on boot. So I save the data required by LMIC_setSessionState and the frame counts after each EV_TXCOMPLETE, and call LMIC_setSessionState and then set the frame counts in LMIC on boot.

This results in my next uplink getting a EV_TXCOMPLETE straight away, with no EV_TXSTART.

Is this relatively simple to do, even if not officially supported, or should I go with a join on reboot? Or can I use this info to do ABP if I have it?

It raised more questions in any case, such as needing to figure out if the network still believes the node is still joined - LMIC_sendAlive?

After initial boot and join, sends messages ok.

2022-05-30 05:08:01 /  00003508347: Woke up
2022-05-30 05:08:01 /  00003509691: ============================================================
2022-05-30 05:08:01 /  00003511035: Reading soil
2022-05-30 05:08:01 /  00003530427: Expected 2 values, received: -1
2022-05-30 05:08:01 /  00003531579: Reading NDVI
2022-05-30 05:08:02 /  00003567355: Expected 3 values, received: -1
2022-05-30 05:08:02 /  00003568667: measuredvbat as read: 418
2022-05-30 05:08:02 /  00003569819: measuredvbat adjusted: 269.414062
2022-05-30 05:08:02 /  00003571259: EV_TXSTART
2022-05-30 05:08:09 /  00003773275: EV_TXCOMPLETE (includes waiting for RX windows)
2022-05-30 05:08:09 /  00003774587: have_deadline: 0, next deadline: 0
2022-05-30 05:08:09 /  00003775739: Setting next sensor read alarm
2022-05-30 05:08:09 /  00003777275: Abs wake at 15:09:00
2022-05-30 05:08:09 /  00003779195: save_mac_state
2022-05-30 05:08:09 /  00003780347: netid = 19
2022-05-30 05:08:09 /  00003781499: devaddr = ......
2022-05-30 05:08:09 /  00003782651: nwkKey
 1c ... 04
2022-05-30 05:08:09 /  00003783867: artKey
 e7 ... 3f
2022-05-30 05:08:09 /  00003785083: seqnoUp = 4
2022-05-30 05:08:09 /  00003786235: seqnoDn = 2
2022-05-30 05:08:09 /  00003787419: Standby

Now I press the reset button, and the state gets loaded in from flash, but I don’t see an EV_TXSTART and no message is sent.

2022-05-30 05:08:23 /  00000002502: restore_mac_state
2022-05-30 05:08:23 /  00000003654: netid = 19
2022-05-30 05:08:23 /  00000004806: devaddr = ......
2022-05-30 05:08:23 /  00000005958: nwkKey
 1c ... 04
2022-05-30 05:08:23 /  00000007142: artKey
 e7... 3f
2022-05-30 05:08:23 /  00000008326: seqnoUp = 4
2022-05-30 05:08:23 /  00000009478: seqnoDn = 2
2022-05-30 05:08:23 /  00000010630: setup done
2022-05-30 05:08:23 /  00000011782: ============================================================
2022-05-30 05:08:23 /  00000013126: Reading soil
2022-05-30 05:08:24 /  00000048870: Expected 2 values, received: -1
2022-05-30 05:08:24 /  00000050022: Reading NDVI
2022-05-30 05:08:25 /  00000085766: Expected 3 values, received: -1
2022-05-30 05:08:25 /  00000087078: measuredvbat as read: 416
2022-05-30 05:08:25 /  00000088230: measuredvbat adjusted: 268.125000
2022-05-30 05:08:25 /  00000089382: Adding DeviceTimeReq MAC command to uplink.
2022-05-30 05:08:25 /  00000090534: EV_TXCOMPLETE (includes waiting for RX windows)