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 }) -}