Skip to content

Commit 9ad39b7

Browse files
committed
Set CRC status for BasicStation and UDP Packet Forwarder.
For the BasicStation it is assumed that it will only forward when the CRC is valid.
1 parent 639e44b commit 9ad39b7

File tree

9 files changed

+32
-6
lines changed

9 files changed

+32
-6
lines changed

internal/backend/basicstation/backend_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func (ts *BackendTestSuite) TestUplinkDataFrame() {
180180
Rssi: 120,
181181
LoraSnr: 5.5,
182182
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
183+
CrcStatus: gw.CRCStatus_CRC_OK,
183184
},
184185
}, uplinkFrame)
185186
}
@@ -232,6 +233,7 @@ func (ts *BackendTestSuite) TestJoinRequest() {
232233
Rssi: 120,
233234
LoraSnr: 5.5,
234235
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
236+
CrcStatus: gw.CRCStatus_CRC_OK,
235237
},
236238
}, uplinkFrame)
237239
}
@@ -279,6 +281,7 @@ func (ts *BackendTestSuite) TestProprietaryDataFrame() {
279281
Rssi: 120,
280282
LoraSnr: 5.5,
281283
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
284+
CrcStatus: gw.CRCStatus_CRC_OK,
282285
},
283286
}, uplinkFrame)
284287
}

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
LoraSnr: 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
@@ -70,6 +70,7 @@ func SetRadioMetaDataToProto(loraBand band.Band, gatewayID lorawan.EUI64, rmd Ra
7070
GatewayId: gatewayID[:],
7171
Rssi: int32(rmd.UpInfo.RSSI),
7272
LoraSnr: float64(rmd.UpInfo.SNR),
73+
CrcStatus: gw.CRCStatus_CRC_OK,
7374
}
7475

7576
if gpsTime := rmd.UpInfo.GPSTime; gpsTime != 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
LoraSnr: 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
},
@@ -83,6 +84,7 @@ func TestSetRadioMetaDataToProto(t *testing.T) {
8384
GatewayId: []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08},
8485
Rssi: 120,
8586
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
87+
CrcStatus: gw.CRCStatus_CRC_OK,
8688
},
8789
},
8890
},
@@ -118,6 +120,7 @@ func TestSetRadioMetaDataToProto(t *testing.T) {
118120
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
119121
TimeSinceGpsEpoch: ptypes.DurationProto(5 * time.Second),
120122
Time: timeP,
123+
CrcStatus: gw.CRCStatus_CRC_OK,
121124
},
122125
},
123126
},

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
LoraSnr: 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
},
@@ -102,6 +103,7 @@ func TestUplinkDataFrameToProto(t *testing.T) {
102103
Rssi: 120,
103104
LoraSnr: 5.5,
104105
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
106+
CrcStatus: gw.CRCStatus_CRC_OK,
105107
},
106108
},
107109
},
@@ -146,6 +148,7 @@ func TestUplinkDataFrameToProto(t *testing.T) {
146148
Rssi: 120,
147149
LoraSnr: 5.5,
148150
Context: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
151+
CrcStatus: gw.CRCStatus_CRC_OK,
149152
},
150153
},
151154
},

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
LoraSnr: 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_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,12 @@ func (ts *BackendTestSuite) TestPushData() {
319319
TimeSinceGpsEpoch: &duration.Duration{
320320
Seconds: 1,
321321
},
322-
Rssi: -51,
323-
LoraSnr: 7,
324-
Channel: 2,
325-
RfChain: 1,
326-
Context: []byte{0x2a, 0x33, 0x7a, 0xb3},
322+
Rssi: -51,
323+
LoraSnr: 7,
324+
Channel: 2,
325+
RfChain: 1,
326+
Context: []byte{0x2a, 0x33, 0x7a, 0xb3},
327+
CrcStatus: gw.CRCStatus_CRC_OK,
327328
},
328329
},
329330
},

internal/backend/semtechudp/packets/push_data.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ func getUplinkFrame(gatewayID []byte, rxpk RXPK, FakeRxInfoTime bool) (gw.Uplink
169169
},
170170
}
171171

172+
switch rxpk.Stat {
173+
case 1:
174+
frame.RxInfo.CrcStatus = gw.CRCStatus_CRC_OK
175+
case -1:
176+
frame.RxInfo.CrcStatus = gw.CRCStatus_BAD_CRC
177+
default:
178+
frame.RxInfo.CrcStatus = gw.CRCStatus_NO_CRC
179+
}
180+
172181
// Context
173182
binary.BigEndian.PutUint32(frame.RxInfo.Context, rxpk.Tmst)
174183

internal/backend/semtechudp/packets/push_data_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func TestGetUplinkFrame(t *testing.T) {
245245
Board: 2,
246246
Antenna: 0,
247247
Context: []byte{0x00, 0x0f, 0x42, 0x40},
248+
CrcStatus: gw.CRCStatus_BAD_CRC,
248249
},
249250
},
250251
},
@@ -302,6 +303,7 @@ func TestGetUplinkFrame(t *testing.T) {
302303
Board: 2,
303304
Antenna: 0,
304305
Context: []byte{0x00, 0x0f, 0x42, 0x40},
306+
CrcStatus: gw.CRCStatus_CRC_OK,
305307
},
306308
},
307309
},
@@ -381,7 +383,8 @@ func TestGetUplinkFrame(t *testing.T) {
381383
EncryptedNs: []byte{2, 3, 4, 5},
382384
},
383385
},
384-
Context: []byte{0x00, 0x0f, 0x42, 0x40},
386+
Context: []byte{0x00, 0x0f, 0x42, 0x40},
387+
CrcStatus: gw.CRCStatus_CRC_OK,
385388
},
386389
},
387390
{
@@ -409,6 +412,7 @@ func TestGetUplinkFrame(t *testing.T) {
409412
Board: 2,
410413
Antenna: 9,
411414
Context: []byte{0x00, 0x0f, 0x42, 0x40},
415+
CrcStatus: gw.CRCStatus_CRC_OK,
412416
},
413417
},
414418
},

0 commit comments

Comments
 (0)