@@ -2,6 +2,7 @@ package structs
2
2
3
3
import (
4
4
"encoding/binary"
5
+ "math"
5
6
"time"
6
7
7
8
"github.com/brocaar/chirpstack-api/go/v3/common"
@@ -22,6 +23,7 @@ type RadioMetaData struct {
22
23
23
24
// RadioMetaDataUpInfo contains the radio meta-data uplink info.
24
25
type RadioMetaDataUpInfo struct {
26
+ RxTime float64 `json:"rxtime"`
25
27
RCtx uint64 `json:"rctx"`
26
28
XTime uint64 `json:"xtime"`
27
29
GPSTime int64 `json:"gpstime"`
@@ -80,11 +82,22 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
80
82
pb .RxInfo .TimeSinceGpsEpoch = ptypes .DurationProto (gpsTimeDur )
81
83
pb .RxInfo .Time , err = ptypes .TimestampProto (gpsTimeTime )
82
84
if err != nil {
83
- return errors .Wrap (err , "timestamp proto error" )
85
+ return errors .Wrap (err , "GPSTime/ timestamp proto error" )
84
86
}
85
87
86
88
}
87
89
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
+
88
101
// Context
89
102
pb .RxInfo .Context = make ([]byte , 16 )
90
103
binary .BigEndian .PutUint64 (pb .RxInfo .Context [0 :8 ], uint64 (rmd .UpInfo .RCtx ))
0 commit comments