[fix](trx-wspr): clear decoder warnings

Keep protocol items before tests and rewrite warning-triggering loops.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-18 22:34:43 +01:00
parent 5dabe32106
commit 7cc8490024
2 changed files with 15 additions and 16 deletions
+4 -5
View File
@@ -290,8 +290,8 @@ mod tests {
let base_hz = 1496.0_f32; let base_hz = 1496.0_f32;
let start = EXPECTED_SIGNAL_START_SAMPLES; let start = EXPECTED_SIGNAL_START_SAMPLES;
for sym in 0..WSPR_SYMBOL_COUNT { for (sym, sync_tone) in SYNC_VECTOR.iter().copied().enumerate().take(WSPR_SYMBOL_COUNT) {
let tone = SYNC_VECTOR[sym] + 2 * ((sym % 2) as u8); let tone = sync_tone + 2 * ((sym % 2) as u8);
let freq = base_hz + tone as f32 * TONE_SPACING_HZ; let freq = base_hz + tone as f32 * TONE_SPACING_HZ;
let begin = start + sym * WSPR_SYMBOL_SAMPLES; let begin = start + sym * WSPR_SYMBOL_SAMPLES;
for i in 0..WSPR_SYMBOL_SAMPLES { for i in 0..WSPR_SYMBOL_SAMPLES {
@@ -347,9 +347,8 @@ mod tests {
// Generate a synthetic WSPR-like signal using the sync vector // Generate a synthetic WSPR-like signal using the sync vector
let mut signal = vec![0.0_f32; WSPR_SIGNAL_SAMPLES]; let mut signal = vec![0.0_f32; WSPR_SIGNAL_SAMPLES];
for sym in 0..WSPR_SYMBOL_COUNT { for (sym, sync_tone) in SYNC_VECTOR.iter().copied().enumerate().take(WSPR_SYMBOL_COUNT) {
let tone = SYNC_VECTOR[sym]; // just sync, no data let freq = base_hz + sync_tone as f32 * TONE_SPACING_HZ;
let freq = base_hz + tone as f32 * TONE_SPACING_HZ;
let begin = sym * WSPR_SYMBOL_SAMPLES; let begin = sym * WSPR_SYMBOL_SAMPLES;
for i in 0..WSPR_SYMBOL_SAMPLES { for i in 0..WSPR_SYMBOL_SAMPLES {
let t = i as f32 / WSPR_SAMPLE_RATE as f32; let t = i as f32 / WSPR_SAMPLE_RATE as f32;
+11 -11
View File
@@ -226,6 +226,17 @@ fn unpack_message(bits: &[u8; NBITS]) -> Option<String> {
Some(format!("{} {} {}", callsign, grid, power_dbm)) Some(format!("{} {} {}", callsign, grid, power_dbm))
} }
/// Attempt protocol-level decode from 162 4-FSK symbols.
pub fn decode_symbols(symbols: &[u8]) -> Option<WsprProtocolMessage> {
if symbols.len() < NSYMS {
return None;
}
let coded = deinterleave(symbols);
let bits = fano_decode(&coded)?;
let message = unpack_message(&bits)?;
Some(WsprProtocolMessage { message })
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@@ -285,14 +296,3 @@ mod tests {
assert!(msg.contains("37"), "power not found in '{}'", msg); assert!(msg.contains("37"), "power not found in '{}'", msg);
} }
} }
/// Attempt protocol-level decode from 162 4-FSK symbols.
pub fn decode_symbols(symbols: &[u8]) -> Option<WsprProtocolMessage> {
if symbols.len() < NSYMS {
return None;
}
let coded = deinterleave(symbols);
let bits = fano_decode(&coded)?;
let message = unpack_message(&bits)?;
Some(WsprProtocolMessage { message })
}