mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-03-03 04:08:35 +00:00
Return LinkCheckAns with margin=0 for non-LoRa modulations.
This commit is contained in:
parent
8cb2d4f383
commit
99613014ad
@ -27,31 +27,40 @@ pub fn handle(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| anyhow!("parameters can not be None"))?;
|
.ok_or_else(|| anyhow!("parameters can not be None"))?;
|
||||||
|
|
||||||
if let gw::modulation::Parameters::Lora(pl) = mod_params {
|
// For non-LoRa modulations, the margin will be set to 0, as it can not be calculated.
|
||||||
let required_snr = config::get_required_snr_for_sf(pl.spreading_factor as u8)?;
|
// This way, at least the gw_cnt can be provided and the end-device is able to confirm
|
||||||
let mut max_snr: f32 = 0.0;
|
// it is still connected.
|
||||||
|
let margin = match mod_params {
|
||||||
|
gw::modulation::Parameters::Lora(pl) => {
|
||||||
|
let required_snr = config::get_required_snr_for_sf(pl.spreading_factor as u8)?;
|
||||||
|
let mut max_snr: f32 = 0.0;
|
||||||
|
|
||||||
for (i, rx_info) in ufs.rx_info_set.iter().enumerate() {
|
for (i, rx_info) in ufs.rx_info_set.iter().enumerate() {
|
||||||
if i == 0 || rx_info.snr > max_snr {
|
if i == 0 || rx_info.snr > max_snr {
|
||||||
max_snr = rx_info.snr;
|
max_snr = rx_info.snr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let margin = max_snr - required_snr;
|
||||||
|
if margin < 0.0 {
|
||||||
|
0.0
|
||||||
|
} else {
|
||||||
|
margin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {
|
||||||
let mut margin = max_snr - required_snr;
|
warn!("Modulation does not provide margin to LinkCheckReq");
|
||||||
if margin < 0.0 {
|
0.0
|
||||||
margin = 0.0;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return Ok(Some(lrwn::MACCommandSet::new(vec![
|
// We always return a LinkCheckAns, even
|
||||||
lrwn::MACCommand::LinkCheckAns(lrwn::LinkCheckAnsPayload {
|
Ok(Some(lrwn::MACCommandSet::new(vec![
|
||||||
margin: margin as u8,
|
lrwn::MACCommand::LinkCheckAns(lrwn::LinkCheckAnsPayload {
|
||||||
gw_cnt: ufs.rx_info_set.len() as u8,
|
margin: margin as u8,
|
||||||
}),
|
gw_cnt: ufs.rx_info_set.len() as u8,
|
||||||
])));
|
}),
|
||||||
}
|
])))
|
||||||
|
|
||||||
warn!("Unsupported modulation for LinkCheckReq");
|
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user