From 8ffdb9bd209b8aa0f5d7e0e8dcb4ff0332cc5885 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 16 Jan 2017 13:10:23 +0100 Subject: [PATCH] Optional non Embedded LC data suppression --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ DMRControl.cpp | 4 ++-- DMRControl.h | 2 +- DMRSlot.cpp | 52 +++++++++++++++++++++++++++++++++----------------- DMRSlot.h | 4 +++- MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- 8 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 82158a7..851dbe7 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -104,6 +104,7 @@ m_dmrBeacons(false), m_dmrId(0U), m_dmrColorCode(2U), m_dmrSelfOnly(false), +m_dmrEmbeddedLCOnly(false), m_dmrPrefixes(), m_dmrBlackList(), m_dmrWhiteList(), @@ -370,6 +371,8 @@ bool CConf::read() m_dmrColorCode = (unsigned int)::atoi(value); else if (::strcmp(key, "SelfOnly") == 0) m_dmrSelfOnly = ::atoi(value) == 1; + else if (::strcmp(key, "EmbeddedLCOnly") == 0) + m_dmrEmbeddedLCOnly = ::atoi(value) == 1; else if (::strcmp(key, "Prefixes") == 0) { char* p = ::strtok(value, ",\r\n"); while (p != NULL) { @@ -801,6 +804,11 @@ bool CConf::getDMRSelfOnly() const return m_dmrSelfOnly; } +bool CConf::getDMREmbeddedLCOnly() const +{ + return m_dmrEmbeddedLCOnly; +} + std::vector CConf::getDMRPrefixes() const { return m_dmrPrefixes; diff --git a/Conf.h b/Conf.h index 5c94f01..8aca5b0 100644 --- a/Conf.h +++ b/Conf.h @@ -96,6 +96,7 @@ public: bool getDMRBeacons() const; unsigned int getDMRId() const; unsigned int getDMRColorCode() const; + bool getDMREmbeddedLCOnly() const; bool getDMRSelfOnly() const; std::vector getDMRPrefixes() const; std::vector getDMRBlackList() const; @@ -243,6 +244,7 @@ private: unsigned int m_dmrId; unsigned int m_dmrColorCode; bool m_dmrSelfOnly; + bool m_dmrEmbeddedLCOnly; std::vector m_dmrPrefixes; std::vector m_dmrBlackList; std::vector m_dmrWhiteList; diff --git a/DMRControl.cpp b/DMRControl.cpp index cdb12ff..ba7b2d3 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -21,7 +21,7 @@ #include #include -CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) : +CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) : m_id(id), m_colorCode(colorCode), m_modem(modem), @@ -39,7 +39,7 @@ m_lookup(lookup) // Load black and white lists to DMRAccessControl CDMRAccessControl::init(blacklist, whitelist, slot1TGWhitelist, slot2TGWhitelist, selfOnly, prefixes, id); - CDMRSlot::init(colorCode, callHang, modem, network, display, duplex, m_lookup, rssi, jitter); + CDMRSlot::init(colorCode, embeddedLCOnly, callHang, modem, network, display, duplex, m_lookup, rssi, jitter); } CDMRControl::~CDMRControl() diff --git a/DMRControl.h b/DMRControl.h index 466ca2c..2198e63 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -31,7 +31,7 @@ class CDMRControl { public: - CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter); + CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter); ~CDMRControl(); bool processWakeup(const unsigned char* data); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 44f0905..a853439 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -31,6 +31,8 @@ unsigned int CDMRSlot::m_colorCode = 0U; +bool CDMRSlot::m_embeddedLCOnly = false; + CModem* CDMRSlot::m_modem = NULL; CDMRNetwork* CDMRSlot::m_network = NULL; CDisplay* CDMRSlot::m_display = NULL; @@ -584,10 +586,20 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) data[0U] = TAG_DATA; data[1U] = 0x00U; + writeNetworkRF(data, DT_VOICE, errors); + + if (m_embeddedLCOnly) { + // Only send the previously received LC + lcss = m_rfEmbeddedLC.getData(data + 2U, m_rfN); + + // Regenerate the EMB + emb.setColorCode(m_colorCode); + emb.setLCSS(lcss); + emb.getData(data + 2U); + } + if (m_duplex) writeQueueRF(data); - - writeNetworkRF(data, DT_VOICE, errors); } else if (m_rfState == RS_RF_LATE_ENTRY) { CDMREMB emb; emb.putData(data + 2U); @@ -1297,11 +1309,16 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } } - // Regenerate the previous super blocks Embedded Data or substitude the LC for it - if (m_netEmbeddedData[m_netEmbeddedReadN].isValid()) - lcss = m_netEmbeddedData[m_netEmbeddedReadN].getData(data + 2U, dmrData.getN()); - else + if (m_embeddedLCOnly) { + // Only send the previously received LC lcss = m_netEmbeddedLC.getData(data + 2U, dmrData.getN()); + } else { + // Regenerate the previous super blocks Embedded Data or substitude the LC for it + if (m_netEmbeddedData[m_netEmbeddedReadN].isValid()) + lcss = m_netEmbeddedData[m_netEmbeddedReadN].getData(data + 2U, dmrData.getN()); + else + lcss = m_netEmbeddedLC.getData(data + 2U, dmrData.getN()); + } // Regenerate the EMB emb.setColorCode(m_colorCode); @@ -1571,25 +1588,26 @@ void CDMRSlot::writeQueueNet(const unsigned char *data) m_queue.addData(data, len); } -void CDMRSlot::init(unsigned int colorCode, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter) +void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter) { assert(modem != NULL); assert(display != NULL); assert(lookup != NULL); assert(rssiMapper != NULL); - m_colorCode = colorCode; - m_modem = modem; - m_network = network; - m_display = display; - m_duplex = duplex; - m_lookup = lookup; - m_hangCount = callHang * 17U; + m_colorCode = colorCode; + m_embeddedLCOnly = embeddedLCOnly; + m_modem = modem; + m_network = network; + m_display = display; + m_duplex = duplex; + m_lookup = lookup; + m_hangCount = callHang * 17U; - m_rssiMapper = rssiMapper; + m_rssiMapper = rssiMapper; - m_jitterTime = jitter; - m_jitterSlots = jitter / DMR_SLOT_TIME; + m_jitterTime = jitter; + m_jitterSlots = jitter / DMR_SLOT_TIME; m_idle = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; ::memcpy(m_idle, DMR_IDLE_DATA, DMR_FRAME_LENGTH_BYTES + 2U); diff --git a/DMRSlot.h b/DMRSlot.h index e9cab75..ac5290e 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -50,7 +50,7 @@ public: void clock(); - static void init(unsigned int colorCode, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter); + static void init(unsigned int colorCode, bool embeddedLCOnly, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter); private: unsigned int m_slotNo; @@ -98,6 +98,8 @@ private: static unsigned int m_colorCode; + static bool m_embeddedLCOnly; + static CModem* m_modem; static CDMRNetwork* m_network; static CDisplay* m_display; diff --git a/MMDVM.ini b/MMDVM.ini index d94707f..cacc2ff 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -69,6 +69,7 @@ Beacons=1 Id=123456 ColorCode=1 SelfOnly=0 +EmbeddedLCOnly=0 # Prefixes=234,235 # Slot1TGWhiteList= # Slot2TGWhiteList= diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b063c59..22e9707 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -345,6 +345,7 @@ int CMMDVMHost::run() unsigned int id = m_conf.getDMRId(); unsigned int colorCode = m_conf.getDMRColorCode(); bool selfOnly = m_conf.getDMRSelfOnly(); + bool embeddedLCOnly = m_conf.getDMREmbeddedLCOnly(); std::vector prefixes = m_conf.getDMRPrefixes(); std::vector blackList = m_conf.getDMRBlackList(); std::vector whiteList = m_conf.getDMRWhiteList(); @@ -366,6 +367,7 @@ int CMMDVMHost::run() LogInfo(" Id: %u", id); LogInfo(" Color Code: %u", colorCode); LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); + LogInfo(" Embedded LC Only: %s", embeddedLCOnly ? "yes" : "no"); LogInfo(" Prefixes: %u", prefixes.size()); if (blackList.size() > 0U) @@ -380,7 +382,7 @@ int CMMDVMHost::run() LogInfo(" Call Hang: %us", callHang); LogInfo(" TX Hang: %us", txHang); - dmr = new CDMRControl(id, colorCode, callHang, selfOnly, prefixes, blackList, whiteList, slot1TGWhiteList, slot2TGWhiteList, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, m_lookup, rssi, jitter); + dmr = new CDMRControl(id, colorCode, callHang, selfOnly, embeddedLCOnly, prefixes, blackList, whiteList, slot1TGWhiteList, slot2TGWhiteList, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, m_lookup, rssi, jitter); m_dmrTXTimer.setTimeout(txHang); }