RAK3172 LoRaWAN Reconnect

Hello,
I’m using RAK3172-T on my own custom board, working on a project based on RUI3 using Arduino IDE. I tested the example code of (LoRaWAN-OTAA example) where the module connect to the network and send uplink every 20s. In this code I need to check if the connection is lost between the module RAK3172 and the gateway RHF0M30, the system will try to reconnect automatically to the network.
I didn’t find exactly how we can check the lost of connection to rejoin the network. I’ve tested with RUI3 API to get the join status through api.lorawan.njs.get() before every send of uplink, but this method didn’t work.

Thanks.

Welcome to the forum @Zied

api.lorawan.njs.get() is only showing you if the device could join the network, it does not show you whether the connection is active.

You have two options to check the connection to the LoRaWAN server:

(1) Use confirmed uplinks. If the connection works, the LNS will send an ACK back to the device after it received the uplink.

(2) Use the LinkCheck function. This is a request to the LNS that is sent together with an uplink. The LNS will respond with connection information after it received the uplink.

(1) will return an ACK not received error in the callback functions.
(2) will return a failure in the linkcheck callback

Both methods are used in my RUI3-Low-Power example code.