Skip to content

Commit 2591b7a

Browse files
committed
Implement preamble and no_crc fields.
1 parent 0ada5cb commit 2591b7a

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ clap = { version = "4.4", default-features = false, features = [
1616
"usage",
1717
"derive",
1818
] }
19-
chirpstack_api = { version = "4.5", default-features = false, features = [
19+
chirpstack_api = { version = "4.6.0-test.1", default-features = false, features = [
2020
"json",
2121
] }
2222
lrwn_filters = { version = "4.5", features = ["serde"] }

src/backend/semtech_udp/structs.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ impl RxPk {
433433
rx_info: Some(gw::UplinkRxInfo {
434434
gateway_id: hex::encode(gateway_id),
435435
uplink_id,
436-
time: match self.time.map(pbjson_types::Timestamp::from) {
436+
ns_time: None,
437+
gw_time: match self.time.map(pbjson_types::Timestamp::from) {
437438
Some(v) => Some(v),
438439
None => {
439440
if time_fallback_enabled {
@@ -724,12 +725,30 @@ impl PullResp {
724725
gw::modulation::Parameters::Fsk(v) => Some(v.frequency_deviation as u16),
725726
_ => None,
726727
},
727-
ncrc: None,
728+
ncrc: match modulation_params {
729+
gw::modulation::Parameters::Lora(v) => {
730+
if v.no_crc {
731+
Some(v.no_crc)
732+
} else {
733+
None
734+
}
735+
}
736+
_ => None,
737+
},
728738
ipol: match modulation_params {
729739
gw::modulation::Parameters::Lora(v) => Some(v.polarization_inversion),
730740
_ => None,
731741
},
732-
prea: None,
742+
prea: match modulation_params {
743+
gw::modulation::Parameters::Lora(v) => {
744+
if v.preamble > 0 {
745+
Some(v.preamble as u16)
746+
} else {
747+
None
748+
}
749+
}
750+
_ => None,
751+
},
733752
size: item.phy_payload.len() as u16,
734753
data: item.phy_payload.clone(),
735754
},
@@ -1140,7 +1159,7 @@ mod test {
11401159
rx_info: Some(gw::UplinkRxInfo {
11411160
gateway_id: "0102030405060708".into(),
11421161
uplink_id: 123,
1143-
time: Some(pbjson_types::Timestamp::from(now)),
1162+
gw_time: Some(pbjson_types::Timestamp::from(now)),
11441163
rssi: 120,
11451164
snr: 3.5,
11461165
channel: 5,
@@ -1210,7 +1229,7 @@ mod test {
12101229
rx_info: Some(gw::UplinkRxInfo {
12111230
gateway_id: "0102030405060708".into(),
12121231
uplink_id: 123,
1213-
time: Some(pbjson_types::Timestamp::from(now)),
1232+
gw_time: Some(pbjson_types::Timestamp::from(now)),
12141233
time_since_gps_epoch: Some(pbjson_types::Duration::from(Duration::from_secs(
12151234
5
12161235
))),
@@ -1283,7 +1302,7 @@ mod test {
12831302
rx_info: Some(gw::UplinkRxInfo {
12841303
gateway_id: "0102030405060708".into(),
12851304
uplink_id: 123,
1286-
time: Some(pbjson_types::Timestamp::from(now)),
1305+
gw_time: Some(pbjson_types::Timestamp::from(now)),
12871306
time_since_gps_epoch: Some(pbjson_types::Duration::from(
12881307
Duration::from_millis(5_100)
12891308
)),
@@ -1373,7 +1392,7 @@ mod test {
13731392
rx_info: Some(gw::UplinkRxInfo {
13741393
gateway_id: "0102030405060708".into(),
13751394
uplink_id: 123,
1376-
time: Some(pbjson_types::Timestamp::from(now)),
1395+
gw_time: Some(pbjson_types::Timestamp::from(now)),
13771396
rssi: 120,
13781397
snr: 5.4,
13791398
channel: 5,
@@ -1404,7 +1423,7 @@ mod test {
14041423
rx_info: Some(gw::UplinkRxInfo {
14051424
gateway_id: "0102030405060708".into(),
14061425
uplink_id: 123,
1407-
time: Some(pbjson_types::Timestamp::from(now)),
1426+
gw_time: Some(pbjson_types::Timestamp::from(now)),
14081427
rssi: 130,
14091428
snr: 3.5,
14101429
channel: 6,
@@ -1471,7 +1490,7 @@ mod test {
14711490
rx_info: Some(gw::UplinkRxInfo {
14721491
gateway_id: "0102030405060708".into(),
14731492
uplink_id: 123,
1474-
time: Some(pbjson_types::Timestamp::from(now)),
1493+
gw_time: Some(pbjson_types::Timestamp::from(now)),
14751494
rssi: 120,
14761495
channel: 5,
14771496
rf_chain: 1,
@@ -1540,7 +1559,7 @@ mod test {
15401559
rx_info: Some(gw::UplinkRxInfo {
15411560
gateway_id: "0102030405060708".into(),
15421561
uplink_id: 123,
1543-
time: Some(pbjson_types::Timestamp::from(now)),
1562+
gw_time: Some(pbjson_types::Timestamp::from(now)),
15441563
rssi: 120,
15451564
channel: 5,
15461565
rf_chain: 1,
@@ -1614,7 +1633,7 @@ mod test {
16141633
rx_info: Some(gw::UplinkRxInfo {
16151634
gateway_id: "0102030405060708".into(),
16161635
uplink_id: 123,
1617-
time: Some(pbjson_types::Timestamp::from(now)),
1636+
gw_time: Some(pbjson_types::Timestamp::from(now)),
16181637
rssi: 120,
16191638
snr: 3.5,
16201639
channel: 5,
@@ -1667,7 +1686,7 @@ mod test {
16671686
};
16681687
let pl = pl.to_proto_uplink_frames(false).unwrap();
16691688
assert_eq!(1, pl.len());
1670-
assert!(pl[0].rx_info.as_ref().unwrap().time.is_none());
1689+
assert!(pl[0].rx_info.as_ref().unwrap().gw_time.is_none());
16711690
}
16721691

16731692
#[test]
@@ -1702,7 +1721,7 @@ mod test {
17021721
};
17031722
let pl = pl.to_proto_uplink_frames(true).unwrap();
17041723
assert_eq!(1, pl.len());
1705-
assert!(pl[0].rx_info.as_ref().unwrap().time.is_some());
1724+
assert!(pl[0].rx_info.as_ref().unwrap().gw_time.is_some());
17061725
}
17071726

17081727
#[test]

tests/semtech_udp_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async fn end_to_end() {
152152
}),
153153
rx_info: Some(gw::UplinkRxInfo {
154154
gateway_id: "0102030405060708".into(),
155-
time: Some(pbjson_types::Timestamp::from(ts.clone())),
155+
gw_time: Some(pbjson_types::Timestamp::from(ts.clone())),
156156
rssi: -35,
157157
snr: 5.1,
158158
channel: 2,

0 commit comments

Comments
 (0)