Skip to content

Commit

Permalink
gs: drop tmms if invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualguy committed May 21, 2024
1 parent 1970578 commit 4d124a9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 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,14 @@ 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)

if time.Now().Add(gpsTimeDelta).After(ggt) && ggt.Add(gpsTimeDelta).Before(time.Now()) {
goGpsTime = ggt
goTime = goGpsTime
}

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

0 comments on commit 4d124a9

Please sign in to comment.