mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-19 07:48:12 +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:
@ -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) => {
|
||||
|
Reference in New Issue
Block a user