fix: add explicit SF=7 and CR=5 match arms in radio converters

to_sf() relied on the catch-all _ => _7 to handle SF=7, and to_cr()
relied on _ => _4_5 for CR=5. Both work by accident but are misleading
— a reader would think SF=7 and CR=5 are unhandled. Make them explicit.
This commit is contained in:
swaits committed 2026-03-29 21:33:08 -06:00
1 parent b2e8b1d366
commit ee71bb69d3
1 file changed
+4 -2
+4 -2
View File
@@ -289,22 +289,24 @@ fn to_sf(sf: u8) -> lora_phy::mod_params::SpreadingFactor {
match sf { match sf {
5 => _5, 5 => _5,
6 => _6, 6 => _6,
7 => _7,
8 => _8, 8 => _8,
9 => _9, 9 => _9,
10 => _10, 10 => _10,
11 => _11, 11 => _11,
12 => _12, 12 => _12,
_ => _7, // validated earlier, but safe default _ => _7, // validated to 5-12 earlier; unreachable but safe
} }
} }
fn to_cr(cr: u8) -> lora_phy::mod_params::CodingRate { fn to_cr(cr: u8) -> lora_phy::mod_params::CodingRate {
use lora_phy::mod_params::CodingRate::*; use lora_phy::mod_params::CodingRate::*;
match cr { match cr {
5 => _4_5,
6 => _4_6, 6 => _4_6,
7 => _4_7, 7 => _4_7,
8 => _4_8, 8 => _4_8,
_ => _4_5, // validated earlier, but safe default _ => _4_5, // validated to 5-8 earlier; unreachable but safe
} }
} }