@@ -2,6 +2,7 @@ package structs
22
33import (
44 "encoding/binary"
5+ "math"
56 "time"
67
78 "github.com/brocaar/chirpstack-api/go/v3/common"
@@ -22,6 +23,7 @@ type RadioMetaData struct {
2223
2324// RadioMetaDataUpInfo contains the radio meta-data uplink info.
2425type RadioMetaDataUpInfo struct {
26+ RxTime float64 `json:"rxtime"`
2527 RCtx uint64 `json:"rctx"`
2628 XTime uint64 `json:"xtime"`
2729 GPSTime int64 `json:"gpstime"`
@@ -80,11 +82,22 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
8082 pb .RxInfo .TimeSinceGpsEpoch = ptypes .DurationProto (gpsTimeDur )
8183 pb .RxInfo .Time , err = ptypes .TimestampProto (gpsTimeTime )
8284 if err != nil {
83- return errors .Wrap (err , "timestamp proto error" )
85+ return errors .Wrap (err , "GPSTime/ timestamp proto error" )
8486 }
8587
8688 }
8789
90+ if rxTime := rmd .UpInfo .RxTime ; rxTime != 0 {
91+ sec , nsec := math .Modf (rmd .UpInfo .RxTime )
92+ if sec != 0 {
93+ val := time .Unix (int64 (sec ), int64 (nsec ))
94+ pb .RxInfo .Time , err = ptypes .TimestampProto (val )
95+ if err != nil {
96+ return errors .Wrap (err , "rxtime/timestamp proto error" )
97+ }
98+ }
99+ }
100+
88101 // Context
89102 pb .RxInfo .Context = make ([]byte , 16 )
90103 binary .BigEndian .PutUint64 (pb .RxInfo .Context [0 :8 ], uint64 (rmd .UpInfo .RCtx ))
0 commit comments