From fe410b937a9a3c922db5cc7be552d2ed43bedc17 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 28 Jan 2018 23:05:25 -0300 Subject: [PATCH] Adding pseudo YSF2DMR reflector --- YSFGateway/Conf.cpp | 16 ++++++++++++++++ YSFGateway/Conf.h | 4 ++++ YSFGateway/Reflectors.cpp | 19 +++++++++++++++++++ YSFGateway/Reflectors.h | 5 ++++- YSFGateway/WiresX.cpp | 5 +++++ YSFGateway/WiresX.h | 1 + YSFGateway/YSFGateway.cpp | 6 ++++++ YSFGateway/YSFGateway.ini | 2 ++ 8 files changed, 57 insertions(+), 1 deletion(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 4ad3813..eda0178 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -67,6 +67,8 @@ m_networkHosts(), m_networkReloadTime(0U), m_networkParrotAddress("127.0.0.1"), m_networkParrotPort(0U), +m_networkYSF2DMRAddress("127.0.0.1"), +m_networkYSF2DMRPort(0U), m_networkStartup(), m_networkInactivityTimeout(0U), m_networkRevert(false), @@ -186,6 +188,10 @@ bool CConf::read() m_networkParrotAddress = value; else if (::strcmp(key, "ParrotPort") == 0) m_networkParrotPort = (unsigned int)::atoi(value); + else if (::strcmp(key, "YSF2DMRAddress") == 0) + m_networkYSF2DMRAddress = value; + else if (::strcmp(key, "YSF2DMRPort") == 0) + m_networkYSF2DMRPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Startup") == 0) m_networkStartup = value; else if (::strcmp(key, "InactivityTimeout") == 0) @@ -352,6 +358,16 @@ unsigned int CConf::getNetworkParrotPort() const return m_networkParrotPort; } +std::string CConf::getNetworkYSF2DMRAddress() const +{ + return m_networkYSF2DMRAddress; +} + +unsigned int CConf::getNetworkYSF2DMRPort() const +{ + return m_networkYSF2DMRPort; +} + std::string CConf::getNetworkStartup() const { return m_networkStartup; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 71cfde2..3ea4c0d 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -69,6 +69,8 @@ public: unsigned int getNetworkReloadTime() const; std::string getNetworkParrotAddress() const; unsigned int getNetworkParrotPort() const; + std::string getNetworkYSF2DMRAddress() const; + unsigned int getNetworkYSF2DMRPort() const; std::string getNetworkStartup() const; unsigned int getNetworkInactivityTimeout() const; bool getNetworkRevert() const; @@ -110,6 +112,8 @@ private: unsigned int m_networkReloadTime; std::string m_networkParrotAddress; unsigned int m_networkParrotPort; + std::string m_networkYSF2DMRAddress; + unsigned int m_networkYSF2DMRPort; std::string m_networkStartup; unsigned int m_networkInactivityTimeout; bool m_networkRevert; diff --git a/YSFGateway/Reflectors.cpp b/YSFGateway/Reflectors.cpp index d2ac8a6..fe07c34 100644 --- a/YSFGateway/Reflectors.cpp +++ b/YSFGateway/Reflectors.cpp @@ -74,6 +74,12 @@ void CReflectors::setParrot(const std::string& address, unsigned int port) m_parrotPort = port; } +void CReflectors::setYSF2DMR(const std::string& address, unsigned int port) +{ + m_YSF2DMRAddress = address; + m_YSF2DMRPort = port; +} + bool CReflectors::load() { for (std::vector::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) @@ -135,6 +141,19 @@ bool CReflectors::load() LogInfo("Loaded YSF parrot"); } + // Add the YSF2DMR entry + if (m_YSF2DMRPort > 0U) { + CYSFReflector* refl = new CYSFReflector; + refl->m_id = "00002"; + refl->m_name = "YSF2DMR "; + refl->m_desc = "Link YSF2DMR "; + refl->m_address = CUDPSocket::lookup(m_YSF2DMRAddress); + refl->m_port = m_YSF2DMRPort; + refl->m_count = "000"; + m_newReflectors.push_back(refl); + LogInfo("Loaded YSF2DMR"); + } + size = m_newReflectors.size(); if (size == 0U) return false; diff --git a/YSFGateway/Reflectors.h b/YSFGateway/Reflectors.h index d1b1d14..9ba8cb4 100644 --- a/YSFGateway/Reflectors.h +++ b/YSFGateway/Reflectors.h @@ -50,7 +50,8 @@ public: CReflectors(const std::string& hostsFile, unsigned int reloadTime); ~CReflectors(); - void setParrot(const std::string& address, unsigned int port); + void setParrot(const std::string& address, unsigned int port); + void setYSF2DMR(const std::string& address, unsigned int port); bool load(); @@ -68,6 +69,8 @@ private: std::string m_hostsFile; std::string m_parrotAddress; unsigned int m_parrotPort; + std::string m_YSF2DMRAddress; + unsigned int m_YSF2DMRPort; std::vector m_newReflectors; std::vector m_currReflectors; std::vector m_search; diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 006dd65..ec362bb 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -152,6 +152,11 @@ void CWiresX::setParrot(const std::string& address, unsigned int port) m_reflectors.setParrot(address, port); } +void CWiresX::setYSF2DMR(const std::string& address, unsigned int port) +{ + m_reflectors.setYSF2DMR(address, port); +} + bool CWiresX::start() { bool ret = m_reflectors.load(); diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index 6786b82..ba82bd7 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -47,6 +47,7 @@ public: void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); void setParrot(const std::string& address, unsigned int port); + void setYSF2DMR(const std::string& address, unsigned int port); bool start(); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 0648fa6..8f39137 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -221,6 +221,12 @@ int CYSFGateway::run() if (port > 0U) m_wiresX->setParrot(address, port); + address = m_conf.getNetworkYSF2DMRAddress(); + port = m_conf.getNetworkYSF2DMRPort(); + + if (port > 0U) + m_wiresX->setYSF2DMR(address, port); + m_wiresX->start(); if (!startup.empty()) { diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 28043da..f8ccab5 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -40,6 +40,8 @@ Hosts=./YSFHosts.txt ReloadTime=60 ParrotAddress=127.0.0.1 ParrotPort=42012 +YSF2DMRAddress=127.0.0.1 +YSF2DMRPort=42013 # Startup= InactivityTimeout=10 # Revert=0