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

+1 -10
View File
@@ -106,7 +106,7 @@ pub fn dashboard(
Bandwidth::Khz250 => "250kHz",
Bandwidth::Khz500 => "500kHz",
};
let _ = write!(buf, "{} SF{} CR4/{}", bw_str, cfg.sf, cr_denom(cfg.cr));
let _ = write!(buf, "{} SF{} CR4/{}", bw_str, cfg.sf, cfg.cr);
Text::new(&buf, Point::new(0, FONT_H * 2 - 1), style)
.draw(target)
.ok();
@@ -244,12 +244,3 @@ pub fn blank(target: &mut impl DrawTarget<Color = BinaryColor>) {
let _ = target.clear(BinaryColor::Off);
}
fn cr_denom(cr: crate::protocol::CodingRate) -> u8 {
use crate::protocol::CodingRate;
match cr {
CodingRate::Cr4_5 => 5,
CodingRate::Cr4_6 => 6,
CodingRate::Cr4_7 => 7,
CodingRate::Cr4_8 => 8,
}
}