Skip to content

Commit d411d3b

Browse files
committed
Update chirpstack_api + add CrcStatus field back to UplinkRxInfo.
1 parent ad00a52 commit d411d3b

File tree

13 files changed

+47
-14
lines changed

13 files changed

+47
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.17
44

55
require (
66
github.com/brocaar/lorawan v0.0.0-20220207095711-d675789e16ab
7-
github.com/chirpstack/chirpstack/api/go/v4 v4.1.0
7+
github.com/chirpstack/chirpstack/api/go/v4 v4.2.0
88
github.com/eclipse/paho.mqtt.golang v1.4.1
99
github.com/go-zeromq/zmq4 v0.7.0
1010
github.com/golang-jwt/jwt/v4 v4.4.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cb
101101
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
102102
github.com/chirpstack/chirpstack/api/go/v4 v4.1.0 h1:D3ViDwYMmB9yE050i8EbqkGkIkPz8w4NwkdbPk1iat8=
103103
github.com/chirpstack/chirpstack/api/go/v4 v4.1.0/go.mod h1:KBW7imf70O9ifrMmoFH8+dn0+MUFS1PdC5shXH7W3dI=
104+
github.com/chirpstack/chirpstack/api/go/v4 v4.2.0 h1:XswPjMY3Pqqo4V8ZgjhL3MfDeIvmAUakZSxefLj+5U0=
105+
github.com/chirpstack/chirpstack/api/go/v4 v4.2.0/go.mod h1:KBW7imf70O9ifrMmoFH8+dn0+MUFS1PdC5shXH7W3dI=
104106
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
105107
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
106108
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=

internal/backend/basicstation/backend_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func (ts *BackendTestSuite) TestUplinkDataFrame() {
183183
Rssi: 120,
184184
Snr: 5.5,
185185
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
186+
CrcStatus: gw.CRCStatus_CRC_OK,
186187
},
187188
}, uplinkFrame))
188189

@@ -267,6 +268,7 @@ func (ts *BackendTestSuite) TestJoinRequest() {
267268
Rssi: 120,
268269
Snr: 5.5,
269270
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
271+
CrcStatus: gw.CRCStatus_CRC_OK,
270272
},
271273
}, uplinkFrame))
272274

@@ -346,6 +348,7 @@ func (ts *BackendTestSuite) TestProprietaryDataFrame() {
346348
Rssi: 120,
347349
Snr: 5.5,
348350
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
351+
CrcStatus: gw.CRCStatus_CRC_OK,
349352
},
350353
}, uplinkFrame))
351354

internal/backend/basicstation/structs/join_request_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func TestJoinRequestToProto(t *testing.T) {
6666
Rssi: 120,
6767
Snr: 5.5,
6868
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
69+
CrcStatus: gw.CRCStatus_CRC_OK,
6970
},
7071
}, pb)
7172

internal/backend/basicstation/structs/radio_meta_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
7474
GatewayId: gatewayID.String(),
7575
Rssi: int32(rmd.UpInfo.RSSI),
7676
Snr: float32(rmd.UpInfo.SNR),
77+
CrcStatus: gw.CRCStatus_CRC_OK,
7778
}
7879

7980
if rxTime := rmd.UpInfo.RxTime; rxTime != 0 {

internal/backend/basicstation/structs/radio_meta_data_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func TestSetRadioMetaDataToProto(t *testing.T) {
5555
Rssi: 120,
5656
Snr: 5.5,
5757
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
58+
CrcStatus: gw.CRCStatus_CRC_OK,
5859
},
5960
},
6061
},
@@ -84,6 +85,7 @@ func TestSetRadioMetaDataToProto(t *testing.T) {
8485
GatewayId: "0102030405060708",
8586
Rssi: 120,
8687
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
88+
CrcStatus: gw.CRCStatus_CRC_OK,
8789
},
8890
},
8991
},
@@ -120,6 +122,7 @@ func TestSetRadioMetaDataToProto(t *testing.T) {
120122
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
121123
TimeSinceGpsEpoch: durationpb.New(5 * time.Second),
122124
Time: timeP,
125+
CrcStatus: gw.CRCStatus_CRC_OK,
123126
},
124127
},
125128
},

internal/backend/basicstation/structs/uplink_data_frame_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func TestUplinkDataFrameToProto(t *testing.T) {
5959
Rssi: 120,
6060
Snr: 5.5,
6161
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
62+
CrcStatus: gw.CRCStatus_CRC_OK,
6263
},
6364
},
6465
},
@@ -103,6 +104,7 @@ func TestUplinkDataFrameToProto(t *testing.T) {
103104
Rssi: 120,
104105
Snr: 5.5,
105106
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
107+
CrcStatus: gw.CRCStatus_CRC_OK,
106108
},
107109
},
108110
},
@@ -148,6 +150,7 @@ func TestUplinkDataFrameToProto(t *testing.T) {
148150
Rssi: 120,
149151
Snr: 5.5,
150152
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
153+
CrcStatus: gw.CRCStatus_CRC_OK,
151154
},
152155
},
153156
},

internal/backend/basicstation/structs/uplink_proprietary_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func TestUplinkProprietaryFrameToProto(t *testing.T) {
5151
Rssi: 120,
5252
Snr: 5.5,
5353
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
54+
CrcStatus: gw.CRCStatus_CRC_OK,
5455
},
5556
},
5657
},

internal/backend/semtechudp/backend.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ type Backend struct {
4242

4343
udpSendChan chan udpPacket
4444

45-
wg sync.WaitGroup
46-
conn *net.UDPConn
47-
closed bool
48-
gateways gateways
49-
fakeRxTime bool
45+
wg sync.WaitGroup
46+
conn *net.UDPConn
47+
closed bool
48+
gateways gateways
49+
fakeRxTime bool
50+
skipCRCCheck bool
5051
}
5152

5253
// NewBackend creates a new backend.
@@ -68,8 +69,9 @@ func NewBackend(conf config.Config) (*Backend, error) {
6869
gateways: gateways{
6970
gateways: make(map[lorawan.EUI64]gateway),
7071
},
71-
fakeRxTime: conf.Backend.SemtechUDP.FakeRxTime,
72-
cache: cache.New(15*time.Second, 15*time.Second),
72+
fakeRxTime: conf.Backend.SemtechUDP.FakeRxTime,
73+
skipCRCCheck: conf.Backend.SemtechUDP.SkipCRCCheck,
74+
cache: cache.New(15*time.Second, 15*time.Second),
7375
}
7476

7577
go func() {
@@ -468,7 +470,7 @@ func (b *Backend) handlePushData(up udpPacket) error {
468470
}
469471

470472
// uplink frames
471-
uplinkFrames, err := p.GetUplinkFrames(b.fakeRxTime)
473+
uplinkFrames, err := p.GetUplinkFrames(b.skipCRCCheck, b.fakeRxTime)
472474
if err != nil {
473475
return errors.Wrap(err, "get uplink frames error")
474476
}

internal/backend/semtechudp/backend_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ func (ts *BackendTestSuite) TestPushData() {
772772
Channel: 2,
773773
RfChain: 1,
774774
Context: []byte{0x2a, 0x33, 0x7a, 0xb3},
775+
CrcStatus: gw.CRCStatus_CRC_OK,
775776
},
776777
},
777778
},

0 commit comments

Comments
 (0)