On which bases the lorasever de-duplicate the uplink data?

hello,

On which bases the lorasever de-duplicate the uplink data?
Is the process based on RSSI, SNR values received?

Thanks,

Best regards,

LoRa Server will receive the same frame once or multiple times, from one or multiple gateways.

When LoRa Server receives the first frame, it will wait for e.g. 200ms (configurable) for other gateways to receive the same data and forward this to LoRa Server. The key in this de-duplication process is the payload. The en-result is one payload and an array of RX parameters (e.g. gateway mac, SNR, RSSI, …).

Then when sending a downlink, LoRa Server decides which gateway is “close” to the device (as in best signal).

You’ll find the de-duplication code here: https://github.com/brocaar/loraserver/blob/master/internal/uplink/collect.go#L32

thanks!
I am not that familiar with go :s
At the end the Lora server will keep the packet that has the strongest RSSI, right?
or does it take into consideration other parameters such as the SNR?

Best regards

In Go, you can have a struct implement the sort interface by declaring Len, Swap and Less methods. The latter is the one that gives the sorting criteria. From /internal/models/packets.go, you can see that RXInfoSet is ordered using the following Less method for the sort interface:

// Less implements sort.Interface.
func (s RXInfoSet) Less(i, j int) bool {
	// in case SNR is equal
	if s[i].LoRaSNR == s[j].LoRaSNR {
		return s[i].RSSI > s[j].RSSI
	}

	// in case the SNR > maxSNRForSort
	if s[i].LoRaSNR > maxSNRForSort && s[j].LoRaSNR > maxSNRForSort {
		return s[i].RSSI > s[j].RSSI
	}

	return s[i].LoRaSNR > s[j].LoRaSNR
}

Thus, if SNRs are equals or they are higher than the maxSNRForSort on two given elements, it’ll sort by RSSI; else, it’ll sort by SNR. Note that it sorts in reverse (descending) order.