From 7cc2a042b5090446d1ad8ac5f24fe9f909f65c5a Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 1 Feb 2018 22:05:17 +0000 Subject: [PATCH] Improve the logic of the repeater, late entry still to finish. --- NXDNCRC.cpp | 13 ------------- NXDNControl.cpp | 15 ++++++++------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/NXDNCRC.cpp b/NXDNCRC.cpp index cccbb84..29da35c 100644 --- a/NXDNCRC.cpp +++ b/NXDNCRC.cpp @@ -17,7 +17,6 @@ */ #include "NXDNCRC.h" -#include "Log.h" #include #include @@ -41,8 +40,6 @@ bool CNXDNCRC::checkCRC6(const unsigned char* in, unsigned int length) WRITE_BIT1(temp, i, b); } - // LogMessage("NXDN, CRC6: new:%02X old:%02X", crc, temp[0U]); - return crc == temp[0U]; } @@ -53,8 +50,6 @@ void CNXDNCRC::encodeCRC6(unsigned char* in, unsigned int length) uint8_t crc[1U]; crc[0U] = createCRC6(in, length); - // LogMessage("NXDN, CRC6: new:%02X", crc[0U]); - unsigned int n = length; for (unsigned int i = 2U; i < 8U; i++, n++) { bool b = READ_BIT1(crc, i); @@ -80,8 +75,6 @@ bool CNXDNCRC::checkCRC12(const unsigned char* in, unsigned int length) WRITE_BIT1(temp2, i, b); } - // LogMessage("NXDN, CRC12: new:%02X%02X old:%02X%02X", temp1[0U], temp1[1U], temp2[0U], temp2[1U]); - return temp1[0U] == temp2[0U] && temp1[1U] == temp2[1U]; } @@ -95,8 +88,6 @@ void CNXDNCRC::encodeCRC12(unsigned char* in, unsigned int length) temp[0U] = (crc >> 8) & 0xFFU; temp[1U] = (crc >> 0) & 0xFFU; - // LogMessage("NXDN, CRC12: new:%02X%02X", temp[0U], temp[1U]); - unsigned int n = length; for (unsigned int i = 4U; i < 16U; i++, n++) { bool b = READ_BIT1(temp, i); @@ -122,8 +113,6 @@ bool CNXDNCRC::checkCRC15(const unsigned char* in, unsigned int length) WRITE_BIT1(temp2, i, b); } - // LogMessage("NXDN, CRC15: new:%02X%02X old:%02X%02X", temp1[0U], temp1[1U], temp2[0U], temp2[1U]); - return temp1[0U] == temp2[0U] && temp1[1U] == temp2[1U]; } @@ -137,8 +126,6 @@ void CNXDNCRC::encodeCRC15(unsigned char* in, unsigned int length) temp[0U] = (crc >> 8) & 0xFFU; temp[1U] = (crc >> 0) & 0xFFU; - // LogMessage("NXDN, CRC15: new:%02X%02X", temp[0U], temp[1U]); - unsigned int n = length; for (unsigned int i = 1U; i < 16U; i++, n++) { bool b = READ_BIT1(temp, i); diff --git a/NXDNControl.cpp b/NXDNControl.cpp index 5f4b626..35973f3 100644 --- a/NXDNControl.cpp +++ b/NXDNControl.cpp @@ -274,7 +274,7 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne return true; } else { - // if (valid) { + if (m_rfState == RS_RF_LISTENING) { unsigned char message[3U]; sacch.getData(message); @@ -300,11 +300,11 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne break; } - // if (m_rfMask != 0x0FU) - // return false; + if (m_rfMask != 0x0FU) + return false; - unsigned char messageType = m_rfLayer3.getMessageType(); - if (messageType != NXDN_MESSAGE_TYPE_VCALL) + bool hasInfo = m_rfLayer3.getHasInfo(); + if (!hasInfo) return false; unsigned short srcId = m_rfLayer3.getSourceUnitId(); @@ -337,9 +337,9 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_rfState = RS_RF_AUDIO; } - // } + } - // if (m_rfState == RS_RF_AUDIO) { + if (m_rfState == RS_RF_AUDIO) { // Regenerate the sync CSync::addNXDNSync(data + 2U); @@ -449,6 +449,7 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_rfFrames++; m_display->writeNXDNRSSI(m_rssi); + } return true; }