From 1825a0a00369bc7705c9f2a7b3b0f9b6fbdaedc2 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Tue, 3 Mar 2026 02:33:33 +0100 Subject: [PATCH] [fix](trx-server): honor CW decode enable flag Gate the CW decoder task on cw_decode_enabled in both startup and state changes. This restores the UI toggle and prevents decode activity when CW decode is off. Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- src/trx-server/src/audio.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/trx-server/src/audio.rs b/src/trx-server/src/audio.rs index f59db18..2d6e8dd 100644 --- a/src/trx-server/src/audio.rs +++ b/src/trx-server/src/audio.rs @@ -1053,7 +1053,8 @@ pub async fn run_cw_decoder( let mut decoder = CwDecoder::new(sample_rate); let mut was_active = false; let mut last_reset_seq: u64 = 0; - let mut active = matches!(state_rx.borrow().status.mode, RigMode::CW | RigMode::CWR); + let mut active = state_rx.borrow().cw_decode_enabled + && matches!(state_rx.borrow().status.mode, RigMode::CW | RigMode::CWR); let mut last_auto = state_rx.borrow().cw_auto; let mut last_wpm = state_rx.borrow().cw_wpm; let mut last_tone = state_rx.borrow().cw_tone_hz; @@ -1066,7 +1067,8 @@ pub async fn run_cw_decoder( match state_rx.changed().await { Ok(()) => { let state = state_rx.borrow(); - active = matches!(state.status.mode, RigMode::CW | RigMode::CWR); + active = state.cw_decode_enabled + && matches!(state.status.mode, RigMode::CW | RigMode::CWR); if active { pcm_rx = pcm_rx.resubscribe(); } @@ -1146,7 +1148,8 @@ pub async fn run_cw_decoder( match changed { Ok(()) => { let state = state_rx.borrow(); - active = matches!(state.status.mode, RigMode::CW | RigMode::CWR); + active = state.cw_decode_enabled + && matches!(state.status.mode, RigMode::CW | RigMode::CWR); if state.cw_auto != last_auto { last_auto = state.cw_auto; decoder.set_auto(last_auto);