Skip to content

Commit

Permalink
Revert "Revert "gs: Ignore stale tmms (#208)" (#209)" (#210)
Browse files Browse the repository at this point in the history
This reverts commit 81a6290.
  • Loading branch information
HalterCru authored May 28, 2024
1 parent 81a6290 commit 2db068a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/ttnpb/udp/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ import (
)

const (
delta = 0.001 // For GPS comparisons
lora = "LORA"
fsk = "FSK"
lrfhss = "LR-FHSS"
gpsTimeDelta = 5 * time.Second // for validating tmms/GPS time
delta = 0.001 // For GPS comparisons
lora = "LORA"
fsk = "FSK"
lrfhss = "LR-FHSS"

// eirpDelta is the delta between EIRP and ERP.
eirpDelta = 2.15
Expand Down Expand Up @@ -201,8 +202,15 @@ func convertUplink(rx RxPacket, md UpstreamMetadata) (*ttnpb.UplinkMessage, erro
var goTime, goGpsTime time.Time
switch {
case rx.Tmms != nil:
goGpsTime = gpstime.Parse(time.Duration(*rx.Tmms) * time.Millisecond)
goTime = goGpsTime

ggt := gpstime.Parse(time.Duration(*rx.Tmms) * time.Millisecond)
currentUTC := time.Now().UTC()
diff := ggt.Sub(currentUTC).Abs().Seconds()
if diff < gpsTimeDelta.Seconds() {
goGpsTime = ggt
goTime = goGpsTime
}

case rx.Time != nil:
goTime = time.Time(*rx.Time)
}
Expand Down

0 comments on commit 2db068a

Please sign in to comment.