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

pull/99/head
Silvano Seva 2022-07-21 22:14:55 +02:00
rodzic 54af6bf429
commit 9c2091c060
3 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -122,7 +122,7 @@ public:
* @return true if CRC of LSF data matches the one stored in the LSF itself,
* false otherwise.
*/
bool valid();
bool valid() const;
/**
* Get underlying data.
@ -150,7 +150,7 @@ private:
* \param len: lenght of the data block, in bytes.
* \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))

Wyświetl plik

@ -88,7 +88,7 @@ void M17LinkSetupFrame::updateCrc()
data.crc = __builtin_bswap16(crc);
}
bool M17LinkSetupFrame::valid()
bool M17LinkSetupFrame::valid() const
{
uint16_t crc = crc16(&data, 28);
if(data.crc == __builtin_bswap16(crc)) return true;
@ -138,7 +138,7 @@ lich_t M17LinkSetupFrame::generateLichSegment(const uint8_t segmentNum)
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);
uint16_t crc = 0xFFFF;

Wyświetl plik

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