refactor: make CodingRate a plain u8 denominator (5-8) on the wire

CodingRate was an enum with repr(u8) values that didn't match postcard's
wire encoding (variant index). Instead of papering over the mismatch,
make cr a plain u8 in RadioConfig. Host sends the denominator directly:
5 for CR 4/5, 6 for CR 4/6, etc. No lookup tables, no index confusion.

Remove CodingRate enum, cr_denom() helper, and the Bandwidth import that
was only needed for cr_denom. ErrorCode repr values also fixed to 0-based.
This commit is contained in:
swaits committed 2026-03-29 20:42:57 -06:00
1 parent 920dd7cef8
commit ece7cbc8ab
4 files changed
+22 -33

No files matched your search

+9 -5
View File
@@ -206,13 +206,17 @@ fn to_sf(sf: u8) -> lora_phy::mod_params::SpreadingFactor {
}
}
fn to_cr(cr: protocol::CodingRate) -> lora_phy::mod_params::CodingRate {
fn to_cr(cr: u8) -> lora_phy::mod_params::CodingRate {
use lora_phy::mod_params::CodingRate::*;
match cr {
protocol::CodingRate::Cr4_5 => _4_5,
protocol::CodingRate::Cr4_6 => _4_6,
protocol::CodingRate::Cr4_7 => _4_7,
protocol::CodingRate::Cr4_8 => _4_8,
5 => _4_5,
6 => _4_6,
7 => _4_7,
8 => _4_8,
_ => {
debug_assert!(false, "BUG: unvalidated CR {}", cr);
_4_5
}
}
}