Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

beitler
Copy link
Contributor

@beitler beitler commented Apr 12, 2024

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.

if rxTime := rmd.UpInfo.RxTime; rxTime != 0 {
sec, nsec := math.Modf(rmd.UpInfo.RxTime)
if sec != 0 {
val := time.Unix(int64(sec), int64(nsec))
pb.RxInfo.GwTime = timestamppb.New(val)
}
}

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
Copy link
Collaborator

brocaar commented Apr 16, 2024

Thanks @beitler 👍

@brocaar brocaar merged commit dfbaf37 into chirpstack:master Apr 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants