Changed M17 RX behaviour so that received stream data is forwarded to codec2 decode only when a full valid LSF is received.

This commit is contained in:
Silvano Seva 2022-07-21 22:14:55 +02:00
parent 54af6bf429
commit 9c2091c060
3 changed files with 6 additions and 5 deletions

View File

@ -122,7 +122,7 @@ public:
* @return true if CRC of LSF data matches the one stored in the LSF itself, * @return true if CRC of LSF data matches the one stored in the LSF itself,
* false otherwise. * false otherwise.
*/ */
bool valid(); bool valid() const;
/** /**
* Get underlying data. * Get underlying data.
@ -150,7 +150,7 @@ private:
* \param len: lenght of the data block, in bytes. * \param len: lenght of the data block, in bytes.
* \return computed CRC16 over the data block. * \return computed CRC16 over the data block.
*/ */
uint16_t crc16(const void *data, const size_t len); uint16_t crc16(const void *data, const size_t len) const;
struct __attribute__((packed)) struct __attribute__((packed))

View File

@ -88,7 +88,7 @@ void M17LinkSetupFrame::updateCrc()
data.crc = __builtin_bswap16(crc); data.crc = __builtin_bswap16(crc);
} }
bool M17LinkSetupFrame::valid() bool M17LinkSetupFrame::valid() const
{ {
uint16_t crc = crc16(&data, 28); uint16_t crc = crc16(&data, 28);
if(data.crc == __builtin_bswap16(crc)) return true; if(data.crc == __builtin_bswap16(crc)) return true;
@ -138,7 +138,7 @@ lich_t M17LinkSetupFrame::generateLichSegment(const uint8_t segmentNum)
return result; return result;
} }
uint16_t M17LinkSetupFrame::crc16(const void *data, const size_t len) uint16_t M17LinkSetupFrame::crc16(const void *data, const size_t len) const
{ {
const uint8_t *ptr = reinterpret_cast< const uint8_t *>(data); const uint8_t *ptr = reinterpret_cast< const uint8_t *>(data);
uint16_t crc = 0xFFFF; uint16_t crc = 0xFFFF;

View File

@ -163,8 +163,9 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
{ {
auto& frame = demodulator.getFrame(); auto& frame = demodulator.getFrame();
auto type = decoder.decodeFrame(frame); auto type = decoder.decodeFrame(frame);
bool lsfOk = decoder.getLsf().valid();
if(type == M17FrameType::STREAM) if((type == M17FrameType::STREAM) && (lsfOk == true))
{ {
M17StreamFrame sf = decoder.getStreamFrame(); M17StreamFrame sf = decoder.getStreamFrame();
codec_pushFrame(sf.payload().data(), false); codec_pushFrame(sf.payload().data(), false);