From 3694da2dcde998206e0ff2869b279e8ff6686818 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 21 Jul 2018 21:01:55 -0400 Subject: [PATCH] Drop duplicate and out-of-sequence DMR audio frames from RF --- DMRSlot.cpp | 12 ++++++++++++ DMRSlot.h | 1 + 2 files changed, 13 insertions(+) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index f50a783..769a114 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -89,6 +89,7 @@ m_rfLC(NULL), m_netLC(NULL), m_rfSeqNo(0U), m_rfN(0U), +m_lastrfN(0U), m_netN(0U), m_networkWatchdog(1000U, 0U, 1500U), m_rfTimeoutTimer(1000U, timeout), @@ -529,6 +530,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) } } else if (audioSync) { if (m_rfState == RS_RF_AUDIO) { + m_lastrfN = 0; // Convert the Audio Sync to be from the BS or MS as needed CSync::addDMRAudioSync(data + 2U, m_duplex); @@ -574,6 +576,11 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfN = data[1U] & 0x0FU; if (m_rfN > 5U) return false; + if (m_rfN == m_lastrfN) + return false; + if (m_rfN != (m_lastrfN + 1U)) + return false; + m_lastrfN = m_rfN; unsigned int errors = 0U; unsigned char fid = m_rfLC->getFID(); @@ -816,6 +823,11 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfN = data[1U] & 0x0FU; if (m_rfN > 5U) return false; + if (m_rfN == m_lastrfN) + return false; + if (m_rfN != (m_lastrfN + 1U)) + return false; + m_lastrfN = m_rfN; // Regenerate the EMB emb.getData(data + 2U); diff --git a/DMRSlot.h b/DMRSlot.h index 4dfbde4..ff00617 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -79,6 +79,7 @@ private: CDMRLC* m_netLC; unsigned char m_rfSeqNo; unsigned char m_rfN; + unsigned char m_lastrfN; unsigned char m_netN; CTimer m_networkWatchdog; CTimer m_rfTimeoutTimer;