lrwn: Fix cargo clippy feedback.

This commit is contained in:
Orne Brocaar 2024-07-09 11:39:32 +01:00
parent 63bc1b57de
commit 4a33f67ed6
2 changed files with 4 additions and 32 deletions

View File

@ -2437,22 +2437,8 @@ impl PowerLevel {
} }
pub fn to_bytes(&self) -> [u8; 2] { pub fn to_bytes(&self) -> [u8; 2] {
let mut wor_snr = self.wor_snr; let wor_snr = self.wor_snr.clamp(-12, 11);
let mut wor_rssi = self.wor_rssi; let wor_rssi = self.wor_rssi.clamp(-142, -15);
// Set to closest possible value.
if wor_snr < -20 {
wor_snr = -20;
}
if wor_snr > 11 {
wor_snr = 11;
}
if wor_rssi > -15 {
wor_rssi = -15;
}
if wor_rssi < -142 {
wor_rssi = -142;
}
// Encode values // Encode values
let wor_snr = (wor_snr + 20) as u8; let wor_snr = (wor_snr + 20) as u8;

View File

@ -33,22 +33,8 @@ impl UplinkMetadata {
return Err(anyhow!("max wor_channel value is 1")); return Err(anyhow!("max wor_channel value is 1"));
} }
let mut snr = self.snr; let snr = self.snr.clamp(-20, 11);
let mut rssi = self.rssi; let rssi = self.rssi.clamp(-142, -15);
// Set to closest possible value.
if snr < -20 {
snr = -20;
}
if snr > 11 {
snr = 11;
}
if rssi > -15 {
rssi = -15;
}
if rssi < -142 {
rssi = -142;
}
// Encode values // Encode values
let snr = (snr + 20) as u8; let snr = (snr + 20) as u8;