diff --git a/M17Defines.h b/M17Defines.h index 65ac8a4..d50dc08 100644 --- a/M17Defines.h +++ b/M17Defines.h @@ -29,13 +29,13 @@ const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U; const uint8_t M17_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U}; const uint8_t M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU}; -const uint8_t M17_EOF_SYNC_BYTES[] = {0x55U, 0x5DU}; +const uint8_t M17_EOT_SYNC_BYTES[] = {0x55U, 0x5DU}; const uint8_t M17_SYNC_BYTES_LENGTH = 2U; const uint16_t M17_LINK_SETUP_SYNC_BITS = 0x55F7U; const uint16_t M17_STREAM_SYNC_BITS = 0xFF5DU; -const uint16_t M17_EOF_SYNC_BITS = 0x555DU; +const uint16_t M17_EOT_SYNC_BITS = 0x555DU; #endif diff --git a/M17RX.cpp b/M17RX.cpp index bcc1d86..9c514d2 100644 --- a/M17RX.cpp +++ b/M17RX.cpp @@ -110,6 +110,14 @@ void CM17RX::processData(bool bit) // Only search for the syncs in the right place +-2 symbols if (m_bufferPtr >= (M17_SYNC_LENGTH_BITS - 2U) && m_bufferPtr <= (M17_SYNC_LENGTH_BITS + 2U)) { + // Fuzzy matching of the link setup sync bit sequence + if (countBits16(m_bitBuffer ^ M17_LINK_SETUP_SYNC_BITS) <= MAX_SYNC_BIT_RUN_ERRS) { + DEBUG2("M17RX: found link setup sync, pos", m_bufferPtr - M17_SYNC_LENGTH_BITS); + m_lostCount = MAX_SYNC_FRAMES; + m_bufferPtr = M17_SYNC_LENGTH_BITS; + m_state = M17RXS_LINK_SETUP; + } + // Fuzzy matching of the stream sync bit sequence if (countBits16(m_bitBuffer ^ M17_STREAM_SYNC_BITS) <= MAX_SYNC_BIT_RUN_ERRS) { DEBUG2("M17RX: found stream sync, pos", m_bufferPtr - M17_SYNC_LENGTH_BITS); @@ -118,12 +126,13 @@ void CM17RX::processData(bool bit) m_state = M17RXS_STREAM; } - // Fuzzy matching of the eof sync bit sequence - if (countBits16(m_bitBuffer ^ M17_EOF_SYNC_BITS) <= MAX_SYNC_BIT_RUN_ERRS) { - DEBUG2("M17RX: found eof sync, pos", m_bufferPtr - M17_SYNC_LENGTH_BITS); + // Fuzzy matching of the EOT sync bit sequence + if (countBits16(m_bitBuffer ^ M17_EOT_SYNC_BITS) <= MAX_SYNC_BIT_RUN_ERRS) { + DEBUG2("M17RX: found eot sync, pos", m_bufferPtr - M17_SYNC_LENGTH_BITS); io.setDecode(false); serial.writeM17EOT(); reset(); + return; } } @@ -138,8 +147,7 @@ void CM17RX::processData(bool bit) reset(); } else { // Write data to host - m_outBuffer[0U] = 0x00U; // Stream data - m_outBuffer[0U] |= m_lostCount == (MAX_SYNC_FRAMES - 1U) ? 0x01U : 0x00U; + m_outBuffer[0U] = m_lostCount == (MAX_SYNC_FRAMES - 1U) ? 0x01U : 0x00U; switch (m_state) { case M17RXS_LINK_SETUP: diff --git a/M17TX.cpp b/M17TX.cpp index dceb8b3..895dab6 100644 --- a/M17TX.cpp +++ b/M17TX.cpp @@ -116,11 +116,11 @@ uint8_t CM17TX::writeEOT() { /* uint16_t space = m_buffer.getSpace(); - if (space < M17_SYNC_LENGTH_BYTES) + if (space < M17_FRAME_LENGTH_BYTES) return 5U; for (uint8_t i = 0U; i < M17_SYNC_LENGTH_BYTES; i++) - m_buffer.put(M17_EOF_SYNC_BYTES[i]); + m_buffer.put(M17_EOT_SYNC_BYTES[i]); */ return 0U; } diff --git a/version.h b/version.h index 0e57912..2eae345 100644 --- a/version.h +++ b/version.h @@ -26,7 +26,7 @@ #define VER_MAJOR "1" #define VER_MINOR "5" #define VER_REV "2" -#define VERSION_DATE "20210908" +#define VERSION_DATE "20210912" #if defined(ZUMSPOT_ADF7021) #define BOARD_INFO "ZUMspot"