Skip to content

Commit

Permalink
gs: Ignore stale tmms (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: onizmx <[email protected]>
  • Loading branch information
virtualguy and onizmx authored May 23, 2024
1 parent 1970578 commit 82b3647
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 82b3647

Please sign in to comment.