I am setting up Seeeduino LoRaWAN boards for long-term data collection. I am able to get them to send data to The Things Network, connecting using OTAA, but would like to make the following changes which I’m unsure about:
- After a successful OTAA join, the board should save the session keys + device address to an attached FRAM board,
- After reset (e.g. after I swap the device batteries), the board should check for saved keys and try using those to resume sending data instead of re-joining the network.
My current code (in which I just save the keys and device address as variables in the Arduino sketch) is here. (I have removed the actual keys for privacy reasons): https://1drv.ms/u/s!AkiygD5K1xshho9sj3pt1X_rf5Mp5g?e=9XB6HL
I have tried commenting out the line for OTAA join to see if it’s possible to send data using the saved keys, but the board returns an error saying it must join the network before sending data. Is there something else I need to do in order to re-establish the connection without re-joining the network (which will generate new keys and device address anyway)?