From 5a2c5698877ceee3fd988814d8eb6ab640425ae3 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 7 Jun 2016 21:17:57 +0100 Subject: [PATCH] Updates to support the YSF Reflector. --- Conf.cpp | 36 ++++++++++++++++++++++++++---------- Conf.h | 12 ++++++++---- MMDVM.ini | 6 ++++-- MMDVMHost.cpp | 16 ++++++++++------ YSFNetwork.cpp | 8 ++++---- YSFNetwork.h | 2 +- 6 files changed, 53 insertions(+), 27 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 4735f75..e2641c8 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -107,8 +107,10 @@ m_dmrNetworkDebug(false), m_dmrNetworkSlot1(true), m_dmrNetworkSlot2(true), m_fusionNetworkEnabled(false), -m_fusionNetworkAddress(), -m_fusionNetworkPort(0U), +m_fusionNetworkMyAddress(), +m_fusionNetworkMyPort(0U), +m_fusionNetworkGwyAddress(), +m_fusionNetworkGwyPort(0U), m_fusionNetworkDebug(false), m_tftSerialPort("/dev/ttyAMA0"), m_tftSerialBrightness(50U), @@ -350,10 +352,14 @@ bool CConf::read() } else if (section == SECTION_FUSION_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fusionNetworkEnabled = ::atoi(value) == 1; - else if (::strcmp(key, "Address") == 0) - m_fusionNetworkAddress = value; - else if (::strcmp(key, "Port") == 0) - m_fusionNetworkPort = (unsigned int)::atoi(value); + else if (::strcmp(key, "MyAddress") == 0) + m_fusionNetworkMyAddress = value; + else if (::strcmp(key, "MyPort") == 0) + m_fusionNetworkMyPort = (unsigned int)::atoi(value); + else if (::strcmp(key, "GwyAddress") == 0) + m_fusionNetworkGwyAddress = value; + else if (::strcmp(key, "GwyPort") == 0) + m_fusionNetworkGwyPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) m_fusionNetworkDebug = ::atoi(value) == 1; } else if (section == SECTION_TFTSERIAL) { @@ -706,14 +712,24 @@ bool CConf::getFusionNetworkEnabled() const return m_fusionNetworkEnabled; } -std::string CConf::getFusionNetworkAddress() const +std::string CConf::getFusionNetworkMyAddress() const { - return m_fusionNetworkAddress; + return m_fusionNetworkMyAddress; } -unsigned int CConf::getFusionNetworkPort() const +unsigned int CConf::getFusionNetworkMyPort() const { - return m_fusionNetworkPort; + return m_fusionNetworkMyPort; +} + +std::string CConf::getFusionNetworkGwyAddress() const +{ + return m_fusionNetworkGwyAddress; +} + +unsigned int CConf::getFusionNetworkGwyPort() const +{ + return m_fusionNetworkGwyPort; } bool CConf::getFusionNetworkDebug() const diff --git a/Conf.h b/Conf.h index 5f0a359..fb4abd8 100644 --- a/Conf.h +++ b/Conf.h @@ -110,8 +110,10 @@ public: // The System Fusion Network section bool getFusionNetworkEnabled() const; - std::string getFusionNetworkAddress() const; - unsigned int getFusionNetworkPort() const; + std::string getFusionNetworkMyAddress() const; + unsigned int getFusionNetworkMyPort() const; + std::string getFusionNetworkGwyAddress() const; + unsigned int getFusionNetworkGwyPort() const; bool getFusionNetworkDebug() const; // The TFTSERIAL section @@ -211,8 +213,10 @@ private: bool m_dmrNetworkSlot2; bool m_fusionNetworkEnabled; - std::string m_fusionNetworkAddress; - unsigned int m_fusionNetworkPort; + std::string m_fusionNetworkMyAddress; + unsigned int m_fusionNetworkMyPort; + std::string m_fusionNetworkGwyAddress; + unsigned int m_fusionNetworkGwyPort; bool m_fusionNetworkDebug; std::string m_tftSerialPort; diff --git a/MMDVM.ini b/MMDVM.ini index a92d104..e514ad4 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -78,8 +78,10 @@ Debug=0 [System Fusion Network] Enable=1 -Address=c4fm.duckdns.org -Port=42000 +MyAddress=127.0.0.1 +MyPort=3200 +GwyAddress=c4fm.duckdns.org +GwyPort=4200 Debug=0 [TFT Serial] diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index eb28ac7..0ba8f05 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -737,15 +737,19 @@ bool CMMDVMHost::createDMRNetwork() bool CMMDVMHost::createYSFNetwork() { - std::string address = m_conf.getFusionNetworkAddress(); - unsigned int port = m_conf.getFusionNetworkPort(); - bool debug = m_conf.getFusionNetworkDebug(); + std::string myAddress = m_conf.getFusionNetworkMyAddress(); + unsigned int myPort = m_conf.getFusionNetworkMyPort(); + std::string gwyAddress = m_conf.getFusionNetworkGwyAddress(); + unsigned int gwyPort = m_conf.getFusionNetworkGwyPort(); + bool debug = m_conf.getFusionNetworkDebug(); LogInfo("System Fusion Network Parameters"); - LogInfo(" Reflector Address: %s", address.c_str()); - LogInfo(" Reflector Port: %u", port); + LogInfo(" Local Address: %s", myAddress.c_str()); + LogInfo(" Local Port: %u", myPort); + LogInfo(" Gateway Address: %s", gwyAddress.c_str()); + LogInfo(" Gateway Port: %u", gwyPort); - m_ysfNetwork = new CYSFNetwork(address, port, m_callsign, debug); + m_ysfNetwork = new CYSFNetwork(myAddress, myPort, gwyAddress, gwyPort, m_callsign, debug); bool ret = m_ysfNetwork->open(); if (!ret) { diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index 081c359..1f75901 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.cpp @@ -28,10 +28,10 @@ const unsigned int BUFFER_LENGTH = 200U; -CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : -m_socket(), +CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gwyAddress, unsigned int gwyPort, const std::string& callsign, bool debug) : +m_socket(myAddress, myPort), m_address(), -m_port(port), +m_port(gwyPort), m_callsign(), m_debug(debug), m_enabled(false), @@ -42,7 +42,7 @@ m_tag(NULL) m_callsign = callsign; m_callsign.resize(YSF_CALLSIGN_LENGTH, ' '); - m_address = CUDPSocket::lookup(address); + m_address = CUDPSocket::lookup(gwyAddress); m_tag = new unsigned char[YSF_CALLSIGN_LENGTH]; ::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH); diff --git a/YSFNetwork.h b/YSFNetwork.h index e32048e..409cd0a 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.h @@ -29,7 +29,7 @@ class CYSFNetwork { public: - CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); + CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gwyAddress, unsigned int gwyPort, const std::string& callsign, bool debug); ~CYSFNetwork(); bool open();