From 10980324dcf750b2b2a603b8cf6bc7fc236863f2 Mon Sep 17 00:00:00 2001 From: jvn314 Date: Fri, 25 Sep 2026 03:49:22 -0500 Subject: [PATCH] meshtastic: add one-shot FIFO timing adjustment Add a pending sample adjustment to the next FIFO consumption and clear it after use or frame reset. Nothing sets a nonzero adjustment yet, so decoding behavior is unchanged. --- plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp | 6 ++++++ plugins/channelrx/demodmeshtastic/meshtasticdemodsink.h | 1 + 2 files changed, 7 insertions(+) diff --git a/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp b/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp index cb7e7da53..2ddc29479 100644 --- a/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp +++ b/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp @@ -65,6 +65,7 @@ MeshtasticDemodSink::MeshtasticDemodSink() : m_loRaFrameSymbolCount(0), m_loRaCFOFrac(0.0f), m_loRaSTOFrac(0.0f), + m_loRaPendingShift(0), m_loRaSFOHat(0.0f), m_loRaSFOCum(0.0f), m_loRaCFOSTOEstimated(false), @@ -535,6 +536,7 @@ void MeshtasticDemodSink::resetLoRaFrameSync() m_loRaAdditionalUpchirps = 0; m_loRaCFOFrac = 0.0f; m_loRaSTOFrac = 0.0f; + m_loRaPendingShift = 0; m_loRaSFOHat = 0.0f; m_loRaSFOCum = 0.0f; m_loRaCFOSTOEstimated = false; @@ -808,6 +810,10 @@ void MeshtasticDemodSink::processSampleLoRa(const Complex& ci) int consumed = processLoRaFrameSyncStep(); + // Apply a one-shot adjustment requested by the step just processed. + consumed += m_loRaPendingShift; + m_loRaPendingShift = 0; + if (consumed <= 0) { consumed = 1; } diff --git a/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.h b/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.h index 9b5fc5155..583a58df5 100644 --- a/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.h +++ b/plugins/channelrx/demodmeshtastic/meshtasticdemodsink.h @@ -147,6 +147,7 @@ private: unsigned int m_loRaFrameSymbolCount; float m_loRaCFOFrac; float m_loRaSTOFrac; + int m_loRaPendingShift; //!< Extra FIFO samples to consume once after the current step float m_loRaSFOHat; float m_loRaSFOCum; bool m_loRaCFOSTOEstimated;