@@ -3,7 +3,6 @@ package structs
33import (
44 "encoding/binary"
55 "math"
6- "os"
76 "time"
87
98 "github.com/brocaar/chirpstack-api/go/v3/common"
@@ -76,6 +75,17 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
7675 CrcStatus : gw .CRCStatus_CRC_OK ,
7776 }
7877
78+ if rxTime := rmd .UpInfo .RxTime ; rxTime != 0 {
79+ sec , nsec := math .Modf (rmd .UpInfo .RxTime )
80+ if sec != 0 {
81+ val := time .Unix (int64 (sec ), int64 (nsec ))
82+ pb .RxInfo .Time , err = ptypes .TimestampProto (val )
83+ if err != nil {
84+ return errors .Wrap (err , "rxtime/timestamp proto error" )
85+ }
86+ }
87+ }
88+
7989 if gpsTime := rmd .UpInfo .GPSTime ; gpsTime != 0 {
8090 gpsTimeDur := time .Duration (gpsTime ) * time .Microsecond
8191 gpsTimeTime := time .Time (gps .NewTimeFromTimeSinceGPSEpoch (gpsTimeDur ))
@@ -88,19 +98,6 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
8898
8999 }
90100
91- // The WORKAROUND_IGNORE_RX_TIME flag is a workaround in case the reported
92- // rxtime from the Basics Station must be ignored (e.g. it is not accurate).
93- if rxTime := rmd .UpInfo .RxTime ; rxTime != 0 && os .Getenv ("WORKAROUND_IGNORE_RX_TIME" ) == "" {
94- sec , nsec := math .Modf (rmd .UpInfo .RxTime )
95- if sec != 0 {
96- val := time .Unix (int64 (sec ), int64 (nsec ))
97- pb .RxInfo .Time , err = ptypes .TimestampProto (val )
98- if err != nil {
99- return errors .Wrap (err , "rxtime/timestamp proto error" )
100- }
101- }
102- }
103-
104101 // Context
105102 pb .RxInfo .Context = make ([]byte , 16 )
106103 binary .BigEndian .PutUint64 (pb .RxInfo .Context [0 :8 ], uint64 (rmd .UpInfo .RCtx ))
0 commit comments