From 8b2544ba85e6f11f1cdc5836b2ac5df202a4770f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 15 Aug 2017 10:11:05 +0100 Subject: [PATCH] Add SelfOnly to YSF. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- YSFControl.cpp | 40 +++++++++++++++++++++++++++++++++++++++- YSFControl.h | 6 +++++- 6 files changed, 58 insertions(+), 3 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 25e30f6..79686dd 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -122,6 +122,7 @@ m_dmrTXHang(4U), m_fusionEnabled(false), m_fusionLowDeviation(false), m_fusionRemoteGateway(false), +m_fusionSelfOnly(false), m_fusionSQLEnabled(false), m_fusionSQL(0U), m_p25Enabled(false), @@ -459,6 +460,8 @@ bool CConf::read() m_fusionSQL = (unsigned int)::atoi(value); } else if (::strcmp(key, "RemoteGateway") == 0) m_fusionRemoteGateway = ::atoi(value) == 1; + else if (::strcmp(key, "SelfOnly") == 0) + m_fusionSelfOnly = ::atoi(value) == 1; } else if (section == SECTION_P25) { if (::strcmp(key, "Enable") == 0) m_p25Enabled = ::atoi(value) == 1; @@ -935,6 +938,11 @@ bool CConf::getFusionRemoteGateway() const return m_fusionRemoteGateway; } +bool CConf::getFusionSelfOnly() const +{ + return m_fusionSelfOnly; +} + bool CConf::getFusionSQLEnabled() const { return m_fusionSQLEnabled; diff --git a/Conf.h b/Conf.h index b66c12d..82f34bb 100644 --- a/Conf.h +++ b/Conf.h @@ -117,6 +117,7 @@ public: bool getFusionEnabled() const; bool getFusionLowDeviation() const; bool getFusionRemoteGateway() const; + bool getFusionSelfOnly() const; bool getFusionSQLEnabled() const; unsigned char getFusionSQL() const; @@ -275,6 +276,7 @@ private: bool m_fusionEnabled; bool m_fusionLowDeviation; bool m_fusionRemoteGateway; + bool m_fusionSelfOnly; bool m_fusionSQLEnabled; unsigned char m_fusionSQL; diff --git a/MMDVM.ini b/MMDVM.ini index 1ab671e..a9722be 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -86,6 +86,7 @@ TXHang=4 [System Fusion] Enable=1 LowDeviation=0 +SelfOnly=0 #DSQ=1 RemoteGateway=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 3dae46e..9e9cd77 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -408,17 +408,19 @@ int CMMDVMHost::run() if (m_ysfEnabled) { bool lowDeviation = m_conf.getFusionLowDeviation(); bool remoteGateway = m_conf.getFusionRemoteGateway(); + bool selfOnly = m_conf.getFusionSelfOnly(); bool sqlEnabled = m_conf.getFusionSQLEnabled(); unsigned char sql = m_conf.getFusionSQL(); LogInfo("YSF Parameters"); LogInfo(" Low Deviation: %s", lowDeviation ? "yes" : "no"); LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no"); + LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); LogInfo(" DSQ: %s", sqlEnabled ? "yes" : "no"); if (sqlEnabled) LogInfo(" DSQ Value: %u", sql); - ysf = new CYSFControl(m_callsign, m_ysfNetwork, m_display, m_timeout, m_duplex, lowDeviation, remoteGateway, rssi); + ysf = new CYSFControl(m_callsign, selfOnly, m_ysfNetwork, m_display, m_timeout, m_duplex, lowDeviation, remoteGateway, rssi); ysf->setSQL(sqlEnabled, sql); } diff --git a/YSFControl.cpp b/YSFControl.cpp index 278ef71..6cf1add 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -23,8 +23,10 @@ // #define DUMP_YSF -CYSFControl::CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) : +CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) : m_callsign(NULL), +m_selfCallsign(NULL), +m_selfOnly(selfOnly), m_network(network), m_display(display), m_duplex(duplex), @@ -81,6 +83,12 @@ m_fp(NULL) for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) m_callsign[i] = node.at(i); + + m_selfCallsign = new unsigned char[YSF_CALLSIGN_LENGTH]; + ::memset(m_selfCallsign, 0x00U, YSF_CALLSIGN_LENGTH); + + for (unsigned int i = 0U; i < callsign.length(); i++) + m_selfCallsign[i] = callsign.at(i); } CYSFControl::~CYSFControl() @@ -88,6 +96,7 @@ CYSFControl::~CYSFControl() delete[] m_netSource; delete[] m_netDest; delete[] m_callsign; + delete[] m_selfCallsign; } void CYSFControl::setSQL(bool on, unsigned char value) @@ -201,6 +210,12 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) m_rfSource = m_rfPayload.getSource(); + if (m_selfOnly) { + bool ret = checkCallsign(m_rfSource); + if (!ret) + return false; + } + unsigned char cm = m_lastFICH.getCM(); if (cm == YSF_CM_GROUP) m_rfDest = (unsigned char*)"ALL "; @@ -375,6 +390,12 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) m_rfSource = m_rfPayload.getSource(); + if (m_selfOnly) { + bool ret = checkCallsign(m_rfSource); + if (!ret) + return false; + } + unsigned char cm = m_lastFICH.getCM(); if (cm == YSF_CM_GROUP) m_rfDest = (unsigned char*)"ALL "; @@ -584,6 +605,12 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) if (m_rfSource == NULL || m_rfDest == NULL) return false; + if (m_selfOnly) { + bool ret = checkCallsign(m_rfSource); + if (!ret) + return false; + } + m_rfFrames = 0U; m_rfErrs = 0U; m_rfBits = 1U; @@ -697,6 +724,12 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) m_rfSource = m_rfPayload.getSource(); + if (m_selfOnly) { + bool ret = checkCallsign(m_rfSource); + if (!ret) + return false; + } + unsigned char cm = m_lastFICH.getCM(); if (cm == YSF_CM_GROUP) m_rfDest = (unsigned char*)"ALL "; @@ -1163,3 +1196,8 @@ void CYSFControl::closeFile() m_fp = NULL; } } + +bool CYSFControl::checkCallsign(const unsigned char* callsign) const +{ + return ::memcmp(callsign, m_selfCallsign, ::strlen((char*)m_selfCallsign)) == 0; +} diff --git a/YSFControl.h b/YSFControl.h index be603ed..a188006 100644 --- a/YSFControl.h +++ b/YSFControl.h @@ -35,7 +35,7 @@ class CYSFControl { public: - CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper); + CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper); ~CYSFControl(); void setSQL(bool on, unsigned char value); @@ -48,6 +48,8 @@ public: private: unsigned char* m_callsign; + unsigned char* m_selfCallsign; + bool m_selfOnly; CYSFNetwork* m_network; CDisplay* m_display; bool m_duplex; @@ -101,6 +103,8 @@ private: bool openFile(); bool writeFile(const unsigned char* data); void closeFile(); + + bool checkCallsign(const unsigned char* callsign) const; }; #endif