From 7e39ea2a7103c68d9e1d5464d3fd5afa01022f18 Mon Sep 17 00:00:00 2001 From: "Marius Petrescu, YO2LOJ" Date: Sat, 11 May 2019 21:02:16 +0300 Subject: [PATCH] Option to filter callsigns without DMR ID from YSF --- YSF2DMR/Conf.cpp | 7 +++++++ YSF2DMR/Conf.h | 2 ++ YSF2DMR/YSF2DMR.cpp | 39 ++++++++++++++++++++++++++------------- YSF2DMR/YSF2DMR.h | 1 + YSF2DMR/YSF2DMR.ini | 1 + 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/YSF2DMR/Conf.cpp b/YSF2DMR/Conf.cpp index 7c4d4ef..8ed8ad8 100644 --- a/YSF2DMR/Conf.cpp +++ b/YSF2DMR/Conf.cpp @@ -240,6 +240,8 @@ bool CConf::read() m_dmrIdLookupFile = value; else if (::strcmp(key, "Time") == 0) m_dmrIdLookupTime = (unsigned int)::atoi(value); + if (::strcmp(key, "DropUnknown") == 0) + m_dmrDropUnknown = ::atoi(value) == 1; } else if (section == SECTION_LOG) { if (::strcmp(key, "FilePath") == 0) m_logFilePath = value; @@ -517,6 +519,11 @@ unsigned int CConf::getDMRIdLookupTime() const return m_dmrIdLookupTime; } +bool CConf::getDMRDropUnknown() const +{ + return m_dmrDropUnknown; +} + unsigned int CConf::getLogDisplayLevel() const { return m_logDisplayLevel; diff --git a/YSF2DMR/Conf.h b/YSF2DMR/Conf.h index 92e8228..4f1faa7 100644 --- a/YSF2DMR/Conf.h +++ b/YSF2DMR/Conf.h @@ -79,6 +79,7 @@ public: // The DMR Id section std::string getDMRIdLookupFile() const; unsigned int getDMRIdLookupTime() const; + bool getDMRDropUnknown() const; // The Log section unsigned int getLogDisplayLevel() const; @@ -141,6 +142,7 @@ private: std::string m_dmrIdLookupFile; unsigned int m_dmrIdLookupTime; + bool m_dmrDropUnknown; unsigned int m_logDisplayLevel; unsigned int m_logFileLevel; diff --git a/YSF2DMR/YSF2DMR.cpp b/YSF2DMR/YSF2DMR.cpp index 7aadb47..6da18b1 100644 --- a/YSF2DMR/YSF2DMR.cpp +++ b/YSF2DMR/YSF2DMR.cpp @@ -292,6 +292,7 @@ int CYSF2DMR::run() m_lookup = new CDMRLookup(lookupFile, reloadTime); m_lookup->read(); + m_dropUnknown = m_conf.getDMRDropUnknown(); if (m_dmrpc) m_dmrflco = FLCO_USER_USER; @@ -581,21 +582,33 @@ int CYSF2DMR::run() m_dmrNetwork->reset(2U); // OE1KBC fix m_srcid = findYSFID(ysfSrc, true); - m_conv.putYSFHeader(); - m_ysfFrames = 0U; + if (m_dropUnknown == 0 || m_srcid != 0) { + ysfWatchdog.start(); + m_dmrNetwork->reset(2U); // OE1KBC fix + m_conv.putYSFHeader(); + m_ysfFrames = 0U; + } + else + { + LogMessage("Dropped source without DMR ID: %s", ysfSrc.c_str()); + } } } else if (fi == YSF_FI_TERMINATOR) { - ysfWatchdog.stop(); - int extraFrames = (m_hangTime / 100U) - m_ysfFrames - 2U; - for (int i = 0U; i < extraFrames; i++) - m_conv.putDummyYSF(); - LogMessage("YSF received end of voice transmission, %.1f seconds", float(m_ysfFrames) / 10.0F); - m_conv.putYSFEOT(); - m_ysfFrames = 0U; + if (m_dropUnknown == 0 || m_srcid != 0) { + ysfWatchdog.stop(); + int extraFrames = (m_hangTime / 100U) - m_ysfFrames - 2U; + for (int i = 0U; i < extraFrames; i++) + m_conv.putDummyYSF(); + LogMessage("YSF received end of voice transmission, %.1f seconds", float(m_ysfFrames) / 10.0F); + m_conv.putYSFEOT(); + m_ysfFrames = 0U; + } } else if (fi == YSF_FI_COMMUNICATIONS) { - ysfWatchdog.start(); - m_conv.putYSF(buffer + 35U); - m_ysfFrames++; + if (m_dropUnknown == 0 || m_srcid != 0) { + ysfWatchdog.start(); + m_conv.putYSF(buffer + 35U); + m_ysfFrames++; + } } } @@ -1255,7 +1268,7 @@ unsigned int CYSF2DMR::findYSFID(std::string cs, bool showdst) dmrpc = false; if (id == 0) { - id = m_defsrcid; + if (m_dropUnknown == 0) id = m_defsrcid; if (showdst) LogMessage("Not DMR ID found, using default ID: %u, DstID: %s%u", id, dmrpc ? "" : "TG ", m_dstid); else diff --git a/YSF2DMR/YSF2DMR.h b/YSF2DMR/YSF2DMR.h index a645e9e..957f796 100644 --- a/YSF2DMR/YSF2DMR.h +++ b/YSF2DMR/YSF2DMR.h @@ -107,6 +107,7 @@ private: bool m_remoteGateway; unsigned int m_hangTime; bool m_firstSync; + bool m_dropUnknown; bool createDMRNetwork(); void createGPS(); diff --git a/YSF2DMR/YSF2DMR.ini b/YSF2DMR/YSF2DMR.ini index 9855351..60c25a3 100644 --- a/YSF2DMR/YSF2DMR.ini +++ b/YSF2DMR/YSF2DMR.ini @@ -46,6 +46,7 @@ Debug=0 [DMR Id Lookup] File=DMRIds.dat Time=24 +DropUnknown=0 [Log] # Logging levels, 0=No logging