From b4cfb1615949c1ea5ae1505abc6be313734a780f Mon Sep 17 00:00:00 2001 From: QIU Date: Mon, 17 Aug 2026 16:54:23 +0000 Subject: [PATCH] fix(radio): don't record frequencies the radio rejected RadioTrackingService wrote lastSetTxFreq/lastSetRxFreq unconditionally after calling setFrequency, ignoring its Boolean result. When the radio rejected the frequency - the FT-817 CAT limit added in the previous commit, a dropped Bluetooth link, or a failed ack - the remembered value no longer matched what the radio actually holds. The manual-tuning detector then saw a phantom dial change on the next read-back (read is the real frequency, lastSet is the one that never landed) and entered tuning mode: it locked onto the wrong base and kept rewriting the radio. Probe of the state machine: before the fix, a rejected 1.26 GHz write against a radio sitting on 145.5 MHz left lastSet at 1.26 GHz, so every subsequent cycle read a 1.1 GHz gap and flagged manual tuning forever. After the fix the lastSet is only updated on success, so the detector sees no change and the loop keeps applying the next valid frequency. Same fix applied to the split IC-705 path (setWorkingFrequency/setTxVfoFrequency). --- .../data/framework/RadioTrackingService.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/core/data/src/main/java/com/rtbishop/look4sat/core/data/framework/RadioTrackingService.kt b/core/data/src/main/java/com/rtbishop/look4sat/core/data/framework/RadioTrackingService.kt index e5a83f7a..c7e6b155 100644 --- a/core/data/src/main/java/com/rtbishop/look4sat/core/data/framework/RadioTrackingService.kt +++ b/core/data/src/main/java/com/rtbishop/look4sat/core/data/framework/RadioTrackingService.kt @@ -267,12 +267,18 @@ class RadioTrackingService( if (tuningRadio.isEmpty()) { if (txNow != null && txNow.isConnected && txRadioFreq != null) { - txNow.setFrequency(txRadioFreq) - lastSetTxFreq = txRadioFreq.toDouble() + // Only remember the frequency we actually wrote: if the radio + // rejects it (FT-817 CAT limit) or the link dropped, keeping + // lastSetTxFreq updated would make the manual-tuning detector + // see a phantom dial change on the next read-back. + if (txNow.setFrequency(txRadioFreq)) { + lastSetTxFreq = txRadioFreq.toDouble() + } } if (rxNow != null && rxNow.isConnected && rxRadioFreq != null) { - rxNow.setFrequency(rxRadioFreq) - lastSetRxFreq = rxRadioFreq.toDouble() + if (rxNow.setFrequency(rxRadioFreq)) { + lastSetRxFreq = rxRadioFreq.toDouble() + } } } @@ -450,13 +456,15 @@ class RadioTrackingService( // 0x25/00 = active (RX) VFO, 0x25/01 = inactive (TX) VFO. if (rxRadioFreq != null) { Log.d(tag, "Split loop RX (0x25/00): ${rxRadioFreq}Hz") - radio.setWorkingFrequency(rxRadioFreq) - lastSetRxFreq = rxRadioFreq.toDouble() + if (radio.setWorkingFrequency(rxRadioFreq)) { + lastSetRxFreq = rxRadioFreq.toDouble() + } } if (txRadioFreq != null) { Log.d(tag, "Split loop TX (0x25/01): ${txRadioFreq}Hz") - radio.setTxVfoFrequency(txRadioFreq) - lastSetTxFreq = txRadioFreq.toDouble() + if (radio.setTxVfoFrequency(txRadioFreq)) { + lastSetTxFreq = txRadioFreq.toDouble() + } } }