chirpstack / chirpstack-gateway-bridge

ChirpStack Gateway Bridge abstracts Packet Forwarder protocols into Protobuf or JSON over MQTT.
https://www.chirpstack.io
MIT License
415 stars 269 forks source link

Fix fractional part of gwTime in case of uplink received via LoRa Basics Station #234

Closed beitler closed 2 months ago

beitler commented 2 months ago

Whenever an uplink is received via a LoRa Basics Station gateway which doesn't gave GPS time available, the fractional second of the receive time is missing in the reported gwTime of the rx_info element. Example:

image

It seems the fractional part of the rxtime (as float) is not properly scaled to nanoseconds before it is cast to int64.

https://github.com/chirpstack/chirpstack-gateway-bridge/blob/6897fe56c2b8e631632fe2ed37e4d6dbd903f563/internal/backend/basicstation/structs/radio_meta_data.go#L80-L86

This PR fixes that.

Note: rxtime in Basics Station is the radio receive time (xtime) converted into UTC. This conversion is susceptible to UTC synchronization issues (e.g. NTP not functioning correctly, or large/asymmetric network latencies in case of LNS-based timesync) and therefore must be used with care by any consumer.

brocaar commented 2 months ago

Thanks @beitler :+1: