To check if a TTN gateway fails, send confirmed

A Node makes OTAA in the beginning. Thus directly at the beginning also ADR and takes the smallest SF. In the best case, a gateway is nearby. SF7 will probably be chosen. But what happens if this gateway goes offline? A node that is supposed to run for several years will not notice and does not restart.

Send confirmed every x times to check!

For example, we can do a software reset every day, but that’s not necessary. That’s why we have to have a downlink, which is triggered regularly to check if everything is okay. Through ADR, every 64 sends a downlink to adapt the SF. But the node never knows when exactly this downlink will happen.
As a result, the node itself must set the time. There is the possibility to set the confirmed-bit in the LoRaWAN. The gateway sends an answer that he has received the packet.
I changed the code to send a message every 64 times with Confirmed. If we get a confirmation, everything goes on as before. If we do not get an answer, we execute a software reset so that OTAA + ABP will be executed again and we will reach a more distant gateway through a higher SF.

If you have not read my article on ABP yet, I recommend it:

We need a few extra lines outside the functions:

The normal sendBytes(…) function is replaced with the following:

So that we can perform a manual reset without having to contact the Arduino, I have also adjusted the message(…) function:

If we now send “01” to FPort 2, we will reset:

In the test I set the value to 20 instead of 64 so I did not have to wait that long. See there, it works:

In the next case I switched off the gateway after 5. The Node did not notice anything at this time and kept sending until no confirmed came back.

If the gateway remains offline for a long time and no one else is nearby, the node will remain in OTAA mode and will go online again once a gateway is within range.
Now we are prepared to install a node in other places where we will not have access without further ado.
I wish you success!

Leave a Comment

Your email address will not be published. Required fields are marked *