Shared is the rxinfo of the uplink msg. Im extracting this uplink message through http integration. When I have multiple gateways I can see time getting appended randomly to the rxinfo object. Could you please help me undestand this. Sometimes, I can find time in rxInfo[0] or rxInfo[1].
Is there a way to get the time of the message received as a fixed key of the uplink message object. This looks like I have to search every time through rxInfo to get the “time”.
If you check internal/api/application_server.go at lora-app-server, you’ll see that the HandleUplinkData method collects all possible rxInfo (as you may get the same message from multiple gateways) and checks for their time:
for _, rxInfo := range req.RxInfo {
var mac lorawan.EUI64
copy(mac[:], rxInfo.GatewayId)
row := handler.RXInfo{
GatewayID: mac,
RSSI: int(rxInfo.Rssi),
LoRaSNR: rxInfo.LoraSnr,
}
if rxInfo.Location != nil {
row.Location = &handler.Location{
Latitude: rxInfo.Location.Latitude,
Longitude: rxInfo.Location.Longitude,
Altitude: rxInfo.Location.Altitude,
}
}
if gw, ok := gws[mac]; ok {
row.Name = gw.Name
}
if rxInfo.Time != nil {
ts, err := ptypes.Timestamp(rxInfo.Time)
if err != nil {
log.WithField("dev_eui", devEUI).WithError(err).Error("parse timestamp error")
} else {
row.Time = &ts
}
}
pl.RXInfo = append(pl.RXInfo, row)
}
I’m taking a wild guess here (I’d have to check this at loraserver's code and don’t have the time right now), but maybe the network server only appends the time to the rxInfo that corresponds to the first message that arrived during the deduplication time. But even if this wasn’t the case, it’s clearly possible to have an rxInfo with null time, so I’d say you should loop through the rxInfo array and check if time is present in them for extraction.
It depends on the packet-forwarder providing this timestamp. In most cases it is only added when the gateway has a GPS synced time-source and has a GPS fix.