mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-21 00:22:57 +00:00
Change LR-FHSS code_rate to CodeRate type.
This commit is contained in:
@ -52,10 +52,10 @@ impl Handler for Algorithm {
|
||||
// Get median RSSI.
|
||||
let med_rssi = get_median(&req.uplink_history);
|
||||
|
||||
// If the median RSSI is below -130, coding-rate 1/3 is recommended,
|
||||
// If the median RSSI is below -130, coding-rate 2/6 is recommended,
|
||||
// if we are on this coding-rate already, there is nothing to do.
|
||||
if let lrwn::region::DataRateModulation::LrFhss(dr) = ¤t_dr {
|
||||
if med_rssi < -130 && dr.coding_rate == "1/3" {
|
||||
if med_rssi < -130 && dr.coding_rate == "2/6" {
|
||||
return Ok(resp);
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ impl Handler for Algorithm {
|
||||
let mut drs: Vec<u8> = Vec::new();
|
||||
|
||||
// Select LR-FHSS data-rate with coding-rate 4/6 (if any available).
|
||||
// Note: that for RSSI (median) < -130, coding-rate 1/3 is recommended.
|
||||
// Note: that for RSSI (median) < -130, coding-rate 2/6 is recommended.
|
||||
// As the median is taken from the uplink history, make sure that we
|
||||
// take the median from a full history table.
|
||||
if med_rssi >= -130 && req.uplink_history.len() == 20 {
|
||||
@ -105,8 +105,8 @@ impl Handler for Algorithm {
|
||||
);
|
||||
}
|
||||
|
||||
// This either means coding-rate 1/3 must be used, or no data-rate with
|
||||
// coding-rate 3/6 is enabled, and thus 1/3 is the only option.
|
||||
// This either means coding-rate 2/6 must be used, or no data-rate with
|
||||
// coding-rate 3/6 is enabled, and thus 2/6 is the only option.
|
||||
if drs.is_empty() {
|
||||
drs.extend_from_slice(
|
||||
&lr_fhss_drs
|
||||
@ -115,7 +115,7 @@ impl Handler for Algorithm {
|
||||
.filter(|dr| {
|
||||
let dr = region_conf.get_data_rate(*dr).unwrap();
|
||||
if let lrwn::region::DataRateModulation::LrFhss(dr) = dr {
|
||||
dr.coding_rate == "1/3"
|
||||
dr.coding_rate == "2/6"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -289,7 +289,9 @@ pub fn ul_meta_data_to_tx_info(ul_meta_data: &ULMetaData) -> Result<gw::UplinkTx
|
||||
lrwn::region::DataRateModulation::LrFhss(v) => {
|
||||
gw::modulation::Parameters::LrFhss(gw::LrFhssModulationInfo {
|
||||
operating_channel_width: v.occupied_channel_width,
|
||||
code_rate: v.coding_rate,
|
||||
code_rate: gw::CodeRate::from_str(&v.coding_rate)
|
||||
.map_err(|e| anyhow!("{}", e))?
|
||||
.into(),
|
||||
// GridSteps: this value can't be derived from a DR?
|
||||
..Default::default()
|
||||
})
|
||||
|
@ -1,3 +1,4 @@
|
||||
use std::str::FromStr;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use anyhow::Result;
|
||||
@ -33,7 +34,7 @@ pub fn get_uplink_dr(region_name: &str, tx_info: &chirpstack_api::gw::UplinkTxIn
|
||||
}
|
||||
chirpstack_api::gw::modulation::Parameters::LrFhss(v) => {
|
||||
lrwn::region::DataRateModulation::LrFhss(lrwn::region::LrFhssDataRate {
|
||||
coding_rate: v.code_rate.clone(),
|
||||
coding_rate: v.code_rate().into(),
|
||||
occupied_channel_width: v.operating_channel_width,
|
||||
})
|
||||
}
|
||||
@ -70,7 +71,9 @@ pub fn set_uplink_modulation(
|
||||
lrwn::region::DataRateModulation::LrFhss(v) => {
|
||||
gw::modulation::Parameters::LrFhss(gw::LrFhssModulationInfo {
|
||||
operating_channel_width: v.occupied_channel_width,
|
||||
code_rate: v.coding_rate,
|
||||
code_rate: gw::CodeRate::from_str(&v.coding_rate)
|
||||
.map_err(|e| anyhow!("{}", e))?
|
||||
.into(),
|
||||
// GridSteps: this value can't be derived from a DR?
|
||||
..Default::default()
|
||||
})
|
||||
|
@ -264,7 +264,7 @@ fn per_modultation_to_per_dr(
|
||||
}
|
||||
gw::modulation::Parameters::LrFhss(v) => {
|
||||
lrwn::region::DataRateModulation::LrFhss(lrwn::region::LrFhssDataRate {
|
||||
coding_rate: v.code_rate.clone(),
|
||||
coding_rate: v.code_rate().into(),
|
||||
occupied_channel_width: v.operating_channel_width,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user