mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-04-08 03:44:19 +00:00
Add coding_rate field to LoraDataRate (+ fix 2.4GHz coding-rate).
Per Regional Parameters Specification, the LoRa modulation always uses coding-rate 4/5, however this is not the case for ISM2400 (which is currently not covered by the reg. params) in which case coding-rate 4/8LI must be used. Closes #51.
This commit is contained in:
parent
0ac4ef51e2
commit
e2214f9485
@ -1,3 +1,5 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Result;
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
@ -65,7 +67,9 @@ pub fn set_tx_info_data_rate(
|
||||
parameters: Some(gw::modulation::Parameters::Lora(gw::LoraModulationInfo {
|
||||
bandwidth: v.bandwidth,
|
||||
spreading_factor: v.spreading_factor as u32,
|
||||
code_rate: chirpstack_api::gw::CodeRate::Cr45.into(),
|
||||
code_rate: gw::CodeRate::from_str(&v.coding_rate)
|
||||
.map_err(|e| anyhow!("{}", e))?
|
||||
.into(),
|
||||
polarization_inversion: true,
|
||||
code_rate_legacy: "".into(),
|
||||
})),
|
||||
|
@ -25,6 +25,7 @@ pub fn get_uplink_dr(region_name: &str, tx_info: &chirpstack_api::gw::UplinkTxIn
|
||||
lrwn::region::DataRateModulation::Lora(lrwn::region::LoraDataRate {
|
||||
spreading_factor: v.spreading_factor as u8,
|
||||
bandwidth: v.bandwidth,
|
||||
coding_rate: v.code_rate().into(),
|
||||
})
|
||||
}
|
||||
chirpstack_api::gw::modulation::Parameters::Fsk(v) => {
|
||||
@ -57,7 +58,9 @@ pub fn set_uplink_modulation(
|
||||
gw::modulation::Parameters::Lora(gw::LoraModulationInfo {
|
||||
bandwidth: v.bandwidth,
|
||||
spreading_factor: v.spreading_factor as u32,
|
||||
code_rate: gw::CodeRate::Cr45.into(),
|
||||
code_rate: gw::CodeRate::from_str(&v.coding_rate)
|
||||
.map_err(|e| anyhow!("{}", e))?
|
||||
.into(),
|
||||
code_rate_legacy: "".into(),
|
||||
polarization_inversion: true,
|
||||
})
|
||||
|
@ -255,6 +255,7 @@ fn per_modultation_to_per_dr(
|
||||
lrwn::region::DataRateModulation::Lora(lrwn::region::LoraDataRate {
|
||||
spreading_factor: v.spreading_factor as u8,
|
||||
bandwidth: v.bandwidth,
|
||||
coding_rate: v.code_rate().into(),
|
||||
})
|
||||
}
|
||||
gw::modulation::Parameters::Fsk(v) => {
|
||||
|
@ -42,6 +42,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -53,6 +54,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -64,6 +66,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -75,6 +78,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -86,6 +90,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -97,6 +102,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -108,6 +114,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -116,6 +123,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -127,6 +135,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -138,6 +147,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -149,6 +159,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -160,6 +171,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -171,6 +183,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -1362,6 +1375,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: true,
|
||||
expected_dr: 0,
|
||||
@ -1370,6 +1384,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: false,
|
||||
expected_dr: 8,
|
||||
@ -1378,6 +1393,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: true,
|
||||
expected_dr: 6,
|
||||
@ -1386,6 +1402,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: false,
|
||||
expected_dr: 12,
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -764,6 +771,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
0,
|
||||
),
|
||||
@ -772,6 +780,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
0,
|
||||
),
|
||||
@ -780,6 +789,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
5,
|
||||
),
|
||||
@ -788,6 +798,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
5,
|
||||
),
|
||||
@ -796,6 +807,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
6,
|
||||
),
|
||||
@ -804,6 +816,7 @@ mod tests {
|
||||
DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
6,
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 6,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -105,6 +112,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 5,
|
||||
bandwidth: 812000,
|
||||
coding_rate: "4/8LI".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -274,25 +274,26 @@ pub struct DataRate {
|
||||
pub modulation: DataRateModulation,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum DataRateModulation {
|
||||
Lora(LoraDataRate),
|
||||
Fsk(FskDataRate),
|
||||
LrFhss(LrFhssDataRate),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct LoraDataRate {
|
||||
pub spreading_factor: u8,
|
||||
pub bandwidth: u32,
|
||||
pub coding_rate: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct FskDataRate {
|
||||
pub bitrate: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct LrFhssDataRate {
|
||||
pub coding_rate: String,
|
||||
pub occupied_channel_width: u32,
|
||||
@ -465,7 +466,7 @@ impl RegionBaseConfig {
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!("Unknown data-rate"))
|
||||
Err(anyhow!("Unknown data-rate: {:?}", modulation))
|
||||
}
|
||||
|
||||
fn get_data_rate(&self, dr: u8) -> Result<DataRateModulation> {
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -83,6 +88,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -94,6 +100,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 250000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
@ -28,6 +28,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -39,6 +40,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -50,6 +52,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -61,6 +64,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -72,6 +76,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -106,6 +111,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -117,6 +123,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 11,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -128,6 +135,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -139,6 +147,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 9,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -150,6 +159,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -161,6 +171,7 @@ impl Configuration {
|
||||
modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 7,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
},
|
||||
),
|
||||
@ -1054,6 +1065,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 10,
|
||||
bandwidth: 125000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: true,
|
||||
expected_dr: 0,
|
||||
@ -1062,6 +1074,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 12,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: false,
|
||||
expected_dr: 8,
|
||||
@ -1070,6 +1083,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: true,
|
||||
expected_dr: 4,
|
||||
@ -1078,6 +1092,7 @@ pub mod test {
|
||||
dr_modulation: DataRateModulation::Lora(LoraDataRate {
|
||||
spreading_factor: 8,
|
||||
bandwidth: 500000,
|
||||
coding_rate: "4/5".into(),
|
||||
}),
|
||||
uplink: false,
|
||||
expected_dr: 12,
|
||||
|
Loading…
x
Reference in New Issue
Block a user