Support uplink backup on gateway

reading the manual of the RAK7249 gateway from RAKwireless, I found an interesting function of uplink backup.

Automatic Data Recovery
This is an important feature that came with the r176 Firmware update. It allows for LoRa Frames to be store on the SD card (provided there is one in the slot), if the LoRa Network Server is unavailable. Upon restoring the connection those buffed messages will be forwarded so no data will be lost. This is done in blocks of 8 (FIFO), until all are cleared from the buffer.

Is it possible to implement a similar functionality with LoRa Gateway Bridge?

I’ve been experimenting with things like this in a fully custom setup

A few problems are making the system really safe in that there’s no way a failure of the card can imperil the ordinary operation of the system - ie, it needs to be a “toss it over the fence” architecture where the main gateway and bridge functionality don’t really care if data is being archived to the card successfully or not. Anything that does care (for example reporting status) needs to not disrupt normal operation. And you don’t want to delay a startup fsck’ing a messed up card.

Another is that to make use of stale traffic, you need a way to relax the fcnt rollback protection and decide to accept frames that fit in between existing ones in the record of a node (for example, some might have been received in real time by another gateway). Also, you can’t play things back in order, because you don’t want to stop the gateway that has reconnected from sending new traffic while it drains its archive; you want to start sending new traffic immediately and gradually fill-in the historic record.

Also if using OTAA you need to archive the details of past sessions, as the address/keys combo that was in use by packets in a gateways archive (especially if it fails entirely and you have to go physically collect it to get the data on the card) may be so stale that the node has re-registered since and now has a different address and keys.

This is already supported in a limited fashion with the LoRa gateway bridge’s MQTT client and QoS > 0. See this thread:

Note that I say limited, as order isn’t guaranteed. But if your device only sends once every couple hours, it will work well for a 10-minute cellular outage.