diff --git a/openrtx/include/protocols/M17/M17Demodulator.h b/openrtx/include/protocols/M17/M17Demodulator.h index 0bbb2fd1..5f5a883e 100644 --- a/openrtx/include/protocols/M17/M17Demodulator.h +++ b/openrtx/include/protocols/M17/M17Demodulator.h @@ -145,7 +145,6 @@ private: uint16_t frame_index; ///< Index for filling the raw frame. frame_t *activeFrame; ///< Half frame, in demodulation. frame_t *idleFrame; ///< Half frame, free to be processed. - bool isLSF; ///< Indicates that we demodualated an LSF. bool syncDetected; ///< A syncword was detected. bool locked; ///< A syncword was correctly demodulated. bool newFrame; ///< A new frame has been fully decoded. diff --git a/openrtx/src/protocols/M17/M17Demodulator.cpp b/openrtx/src/protocols/M17/M17Demodulator.cpp index bff1c8b0..1ec58034 100644 --- a/openrtx/src/protocols/M17/M17Demodulator.cpp +++ b/openrtx/src/protocols/M17/M17Demodulator.cpp @@ -271,11 +271,6 @@ const frame_t& M17Demodulator::getFrame() return *activeFrame; } -bool M17Demodulator::isFrameLSF() -{ - return isLSF; -} - bool M17::M17Demodulator::isLocked() { return locked; @@ -324,7 +319,6 @@ bool M17Demodulator::update() if (syncword.index != -1) // Valid syncword found { syncDetected = true; - isLSF = syncword.lsf; offset = syncword.index + 1; phase = 0; frame_index = 0; @@ -402,7 +396,7 @@ bool M17Demodulator::update() lsf_syncword_bytes[1]); // Too many errors in the syncword, lock is lost - if ((hammingSync > 1) && (hammingLsf > 1)) + if ((hammingSync > 4) && (hammingLsf > 4)) { syncDetected = false; locked = false; diff --git a/openrtx/src/protocols/M17/M17FrameDecoder.cpp b/openrtx/src/protocols/M17/M17FrameDecoder.cpp index 3ec5bc67..89754180 100644 --- a/openrtx/src/protocols/M17/M17FrameDecoder.cpp +++ b/openrtx/src/protocols/M17/M17FrameDecoder.cpp @@ -65,7 +65,9 @@ M17FrameType M17FrameDecoder::decodeFrame(const frame_t& frame) } // Stream data frame - if(syncWord == STREAM_SYNC_WORD) + uint8_t hd = __builtin_popcount(syncWord[0] ^ STREAM_SYNC_WORD[0]) + + __builtin_popcount(syncWord[1] ^ STREAM_SYNC_WORD[1]); + if(hd <= 4) { decodeStream(data); return M17FrameType::STREAM;