From 7cc8490024feb18fb93fcb6c71274ac643b37ec2 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Wed, 18 Mar 2026 22:34:43 +0100 Subject: [PATCH] [fix](trx-wspr): clear decoder warnings Keep protocol items before tests and rewrite warning-triggering loops. Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- src/decoders/trx-wspr/src/decoder.rs | 9 ++++----- src/decoders/trx-wspr/src/protocol.rs | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/decoders/trx-wspr/src/decoder.rs b/src/decoders/trx-wspr/src/decoder.rs index 2ad8308..3df6d16 100644 --- a/src/decoders/trx-wspr/src/decoder.rs +++ b/src/decoders/trx-wspr/src/decoder.rs @@ -290,8 +290,8 @@ mod tests { let base_hz = 1496.0_f32; let start = EXPECTED_SIGNAL_START_SAMPLES; - for sym in 0..WSPR_SYMBOL_COUNT { - let tone = SYNC_VECTOR[sym] + 2 * ((sym % 2) as u8); + for (sym, sync_tone) in SYNC_VECTOR.iter().copied().enumerate().take(WSPR_SYMBOL_COUNT) { + let tone = sync_tone + 2 * ((sym % 2) as u8); let freq = base_hz + tone as f32 * TONE_SPACING_HZ; let begin = start + sym * 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 let mut signal = vec![0.0_f32; WSPR_SIGNAL_SAMPLES]; - for sym in 0..WSPR_SYMBOL_COUNT { - let tone = SYNC_VECTOR[sym]; // just sync, no data - let freq = base_hz + tone as f32 * TONE_SPACING_HZ; + for (sym, sync_tone) in SYNC_VECTOR.iter().copied().enumerate().take(WSPR_SYMBOL_COUNT) { + let freq = base_hz + sync_tone as f32 * TONE_SPACING_HZ; let begin = sym * WSPR_SYMBOL_SAMPLES; for i in 0..WSPR_SYMBOL_SAMPLES { let t = i as f32 / WSPR_SAMPLE_RATE as f32; diff --git a/src/decoders/trx-wspr/src/protocol.rs b/src/decoders/trx-wspr/src/protocol.rs index c9df2e9..428b9a9 100644 --- a/src/decoders/trx-wspr/src/protocol.rs +++ b/src/decoders/trx-wspr/src/protocol.rs @@ -226,6 +226,17 @@ fn unpack_message(bits: &[u8; NBITS]) -> Option { Some(format!("{} {} {}", callsign, grid, power_dbm)) } +/// Attempt protocol-level decode from 162 4-FSK symbols. +pub fn decode_symbols(symbols: &[u8]) -> Option { + 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)] mod tests { use super::*; @@ -285,14 +296,3 @@ mod tests { 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 { - if symbols.len() < NSYMS { - return None; - } - let coded = deinterleave(symbols); - let bits = fano_decode(&coded)?; - let message = unpack_message(&bits)?; - Some(WsprProtocolMessage { message }) -}