From c84df3db5e0cc248df4987ea36e586b51567c625 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 21 Feb 2018 18:41:24 +0000 Subject: [PATCH 01/20] Initial changes ready for FCS support. --- YSFGateway/Makefile | 4 +- YSFGateway/Makefile.Solaris | 4 +- YSFGateway/WiresX.cpp | 4 +- YSFGateway/WiresX.h | 12 +-- YSFGateway/YSFGateway.cpp | 102 +++++++++--------- YSFGateway/YSFGateway.h | 22 ++-- YSFGateway/YSFGateway.vcxproj | 8 +- YSFGateway/YSFGateway.vcxproj.filters | 24 ++--- YSFGateway/{Network.cpp => YSFNetwork.cpp} | 28 ++--- YSFGateway/{Network.h => YSFNetwork.h} | 14 +-- .../{Reflectors.cpp => YSFReflectors.cpp} | 26 ++--- YSFGateway/{Reflectors.h => YSFReflectors.h} | 12 +-- 12 files changed, 130 insertions(+), 130 deletions(-) rename YSFGateway/{Network.cpp => YSFNetwork.cpp} (81%) rename YSFGateway/{Network.h => YSFNetwork.h} (81%) rename YSFGateway/{Reflectors.cpp => YSFReflectors.cpp} (88%) rename YSFGateway/{Reflectors.h => YSFReflectors.h} (88%) diff --git a/YSFGateway/Makefile b/YSFGateway/Makefile index 5646b0c..8e627bd 100644 --- a/YSFGateway/Makefile +++ b/YSFGateway/Makefile @@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ - UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ + UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/Makefile.Solaris b/YSFGateway/Makefile.Solaris index 83461e4..2b533ab 100644 --- a/YSFGateway/Makefile.Solaris +++ b/YSFGateway/Makefile.Solaris @@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread -lsocket LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ - UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ + UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index ec362bb..72d9c4f 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,7 @@ const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U}; const unsigned char NET_HEADER[] = "YSFD ALL "; -CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime) : +CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime) : m_callsign(callsign), m_node(), m_network(network), diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index ba82bd7..847e858 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ #if !defined(WIRESX_H) #define WIRESX_H -#include "Reflectors.h" -#include "Network.h" +#include "YSFReflectors.h" +#include "YSFNetwork.h" #include "Timer.h" #include @@ -42,7 +42,7 @@ enum WXSI_STATUS { class CWiresX { public: - CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime); + CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime); ~CWiresX(); void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); @@ -64,8 +64,8 @@ public: private: std::string m_callsign; std::string m_node; - CNetwork* m_network; - CReflectors m_reflectors; + CYSFNetwork* m_network; + CYSFReflectors m_reflectors; CYSFReflector* m_reflector; std::string m_id; std::string m_name; diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 8f39137..5228f4e 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ */ #include "YSFGateway.h" -#include "Reflectors.h" +#include "YSFReflectors.h" #include "UDPSocket.h" #include "StopWatch.h" #include "Version.h" @@ -81,7 +81,7 @@ m_conf(configFile), m_gps(NULL), m_wiresX(NULL), m_dtmf(NULL), -m_netNetwork(NULL), +m_ysfNetwork(NULL), m_linked(false), m_exclude(false) { @@ -174,7 +174,7 @@ int CYSFGateway::run() std::string myAddress = m_conf.getMyAddress(); unsigned int myPort = m_conf.getMyPort(); - CNetwork rptNetwork(myAddress, myPort, m_callsign, debug); + CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); rptNetwork.setDestination(rptAddress, rptPort); ret = rptNetwork.open(); @@ -186,10 +186,10 @@ int CYSFGateway::run() unsigned int netPort = m_conf.getNetworkPort(); - m_netNetwork = new CNetwork(netPort, m_callsign, debug); - ret = m_netNetwork->open(); + m_ysfNetwork = new CYSFNetwork(netPort, m_callsign, debug); + ret = m_ysfNetwork->open(); if (!ret) { - ::LogError("Cannot open the reflector network port"); + ::LogError("Cannot open the YSF reflector network port"); ::LogFinalise(); return 1; } @@ -234,10 +234,10 @@ int CYSFGateway::run() if (reflector != NULL) { LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); if (!revert) inactivityTimer.start(); @@ -276,17 +276,17 @@ int CYSFGateway::run() WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); switch (status) { case WXS_CONNECT: { - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); CYSFReflector* reflector = m_wiresX->getReflector(); LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); inactivityTimer.start(); lostTimer.start(); @@ -298,10 +298,10 @@ int CYSFGateway::run() case WXS_DISCONNECT: LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); inactivityTimer.stop(); lostTimer.stop(); @@ -330,17 +330,17 @@ int CYSFGateway::run() m_wiresX->processConnect(reflector); if (m_linked) { - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); } LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); inactivityTimer.start(); lostTimer.start(); @@ -356,10 +356,10 @@ int CYSFGateway::run() LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); inactivityTimer.stop(); lostTimer.stop(); @@ -378,7 +378,7 @@ int CYSFGateway::run() } if (networkEnabled && m_linked && !m_exclude) { - m_netNetwork->write(buffer); + m_ysfNetwork->write(buffer); if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) inactivityTimer.start(); } @@ -392,7 +392,7 @@ int CYSFGateway::run() } } - while (m_netNetwork->read(buffer) > 0U) { + while (m_ysfNetwork->read(buffer) > 0U) { if (networkEnabled && m_linked) { // Only pass through YSF data packets if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) @@ -406,7 +406,7 @@ int CYSFGateway::run() stopWatch.start(); rptNetwork.clock(ms); - m_netNetwork->clock(ms); + m_ysfNetwork->clock(ms); if (m_gps != NULL) m_gps->clock(ms); if (m_wiresX != NULL) @@ -424,14 +424,14 @@ int CYSFGateway::run() m_wiresX->processConnect(reflector); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); lostTimer.start(); pollTimer.start(); @@ -441,10 +441,10 @@ int CYSFGateway::run() if (m_wiresX != NULL) m_wiresX->processDisconnect(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); lostTimer.stop(); pollTimer.stop(); @@ -463,7 +463,7 @@ int CYSFGateway::run() if (m_wiresX != NULL) m_wiresX->processDisconnect(); - m_netNetwork->clearDestination(); + m_ysfNetwork->clearDestination(); inactivityTimer.stop(); lostTimer.stop(); @@ -474,7 +474,7 @@ int CYSFGateway::run() pollTimer.clock(ms); if (pollTimer.isRunning() && pollTimer.hasExpired()) { - m_netNetwork->writePoll(); + m_ysfNetwork->writePoll(); pollTimer.start(); } @@ -483,14 +483,14 @@ int CYSFGateway::run() } rptNetwork.close(); - m_netNetwork->close(); + m_ysfNetwork->close(); if (m_gps != NULL) { m_gps->close(); delete m_gps; } - delete m_netNetwork; + delete m_ysfNetwork; delete m_wiresX; delete m_dtmf; diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index ca7ee94..f7c320d 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ #if !defined(YSFGateway_H) #define YSFGateway_H -#include "Network.h" +#include "YSFNetwork.h" #include "WiresX.h" #include "Conf.h" #include "DTMF.h" @@ -36,15 +36,15 @@ public: int run(); private: - std::string m_callsign; - std::string m_suffix; - CConf m_conf; - CGPS* m_gps; - CWiresX* m_wiresX; - CDTMF* m_dtmf; - CNetwork* m_netNetwork; - bool m_linked; - bool m_exclude; + std::string m_callsign; + std::string m_suffix; + CConf m_conf; + CGPS* m_gps; + CWiresX* m_wiresX; + CDTMF* m_dtmf; + CYSFNetwork* m_ysfNetwork; + bool m_linked; + bool m_exclude; void createGPS(); }; diff --git a/YSFGateway/YSFGateway.vcxproj b/YSFGateway/YSFGateway.vcxproj index 386e32f..521ef68 100644 --- a/YSFGateway/YSFGateway.vcxproj +++ b/YSFGateway/YSFGateway.vcxproj @@ -154,8 +154,6 @@ - - @@ -170,7 +168,9 @@ + + @@ -181,8 +181,6 @@ - - @@ -194,7 +192,9 @@ + + diff --git a/YSFGateway/YSFGateway.vcxproj.filters b/YSFGateway/YSFGateway.vcxproj.filters index 20053c3..9065e58 100644 --- a/YSFGateway/YSFGateway.vcxproj.filters +++ b/YSFGateway/YSFGateway.vcxproj.filters @@ -11,9 +11,6 @@ - - Header Files - Header Files @@ -74,9 +71,6 @@ Header Files - - Header Files - Header Files @@ -86,11 +80,14 @@ Header Files + + Header Files + + + Header Files + - - Source Files - Source Files @@ -142,9 +139,6 @@ Source Files - - Source Files - Source Files @@ -154,5 +148,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/YSFGateway/Network.cpp b/YSFGateway/YSFNetwork.cpp similarity index 81% rename from YSFGateway/Network.cpp rename to YSFGateway/YSFNetwork.cpp index f643a43..93e84f0 100644 --- a/YSFGateway/Network.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ */ #include "YSFDefines.h" -#include "Network.h" +#include "YSFNetwork.h" #include "Utils.h" #include "Log.h" @@ -27,7 +27,7 @@ const unsigned int BUFFER_LENGTH = 200U; -CNetwork::CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : +CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : m_socket(address, port), m_debug(debug), m_address(), @@ -51,7 +51,7 @@ m_buffer(1000U, "YSF Network Buffer") } } -CNetwork::CNetwork(unsigned int port, const std::string& callsign, bool debug) : +CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, bool debug) : m_socket(port), m_debug(debug), m_address(), @@ -75,31 +75,31 @@ m_buffer(1000U, "YSF Network Buffer") } } -CNetwork::~CNetwork() +CYSFNetwork::~CYSFNetwork() { delete[] m_poll; } -bool CNetwork::open() +bool CYSFNetwork::open() { LogMessage("Opening YSF network connection"); return m_socket.open(); } -void CNetwork::setDestination(const in_addr& address, unsigned int port) +void CYSFNetwork::setDestination(const in_addr& address, unsigned int port) { m_address = address; m_port = port; } -void CNetwork::clearDestination() +void CYSFNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; m_port = 0U; } -bool CNetwork::write(const unsigned char* data) +bool CYSFNetwork::write(const unsigned char* data) { assert(data != NULL); @@ -112,7 +112,7 @@ bool CNetwork::write(const unsigned char* data) return m_socket.write(data, 155U, m_address, m_port); } -bool CNetwork::writePoll() +bool CYSFNetwork::writePoll() { if (m_port == 0U) return true; @@ -120,7 +120,7 @@ bool CNetwork::writePoll() return m_socket.write(m_poll, 14U, m_address, m_port); } -bool CNetwork::writeUnlink() +bool CYSFNetwork::writeUnlink() { if (m_port == 0U) return true; @@ -128,7 +128,7 @@ bool CNetwork::writeUnlink() return m_socket.write(m_unlink, 14U, m_address, m_port); } -void CNetwork::clock(unsigned int ms) +void CYSFNetwork::clock(unsigned int ms) { if (m_port == 0U) return; @@ -153,7 +153,7 @@ void CNetwork::clock(unsigned int ms) m_buffer.addData(buffer, length); } -unsigned int CNetwork::read(unsigned char* data) +unsigned int CYSFNetwork::read(unsigned char* data) { assert(data != NULL); @@ -168,7 +168,7 @@ unsigned int CNetwork::read(unsigned char* data) return len; } -void CNetwork::close() +void CYSFNetwork::close() { m_socket.close(); diff --git a/YSFGateway/Network.h b/YSFGateway/YSFNetwork.h similarity index 81% rename from YSFGateway/Network.h rename to YSFGateway/YSFNetwork.h index fc023c5..bd8e746 100644 --- a/YSFGateway/Network.h +++ b/YSFGateway/YSFNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef Network_H -#define Network_H +#ifndef YSFNetwork_H +#define YSFNetwork_H #include "YSFDefines.h" #include "UDPSocket.h" @@ -26,11 +26,11 @@ #include #include -class CNetwork { +class CYSFNetwork { public: - CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); - CNetwork(unsigned int port, const std::string& callsign, bool debug); - ~CNetwork(); + CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); + CYSFNetwork(unsigned int port, const std::string& callsign, bool debug); + ~CYSFNetwork(); bool open(); diff --git a/YSFGateway/Reflectors.cpp b/YSFGateway/YSFReflectors.cpp similarity index 88% rename from YSFGateway/Reflectors.cpp rename to YSFGateway/YSFReflectors.cpp index fe07c34..e72661a 100644 --- a/YSFGateway/Reflectors.cpp +++ b/YSFGateway/YSFReflectors.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "Reflectors.h" +#include "YSFReflectors.h" #include "Log.h" #include @@ -26,7 +26,7 @@ #include #include -CReflectors::CReflectors(const std::string& hostsFile, unsigned int reloadTime) : +CYSFReflectors::CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime) : m_hostsFile(hostsFile), m_parrotAddress(), m_parrotPort(0U), @@ -39,7 +39,7 @@ m_timer(1000U, reloadTime * 60U) m_timer.start(); } -CReflectors::~CReflectors() +CYSFReflectors::~CYSFReflectors() { for (std::vector::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) delete *it; @@ -68,19 +68,19 @@ static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2) return false; } -void CReflectors::setParrot(const std::string& address, unsigned int port) +void CYSFReflectors::setParrot(const std::string& address, unsigned int port) { m_parrotAddress = address; m_parrotPort = port; } -void CReflectors::setYSF2DMR(const std::string& address, unsigned int port) +void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned int port) { m_YSF2DMRAddress = address; m_YSF2DMRPort = port; } -bool CReflectors::load() +bool CYSFReflectors::load() { for (std::vector::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) delete *it; @@ -163,24 +163,24 @@ bool CReflectors::load() return true; } -CYSFReflector* CReflectors::find(const std::string& id) +CYSFReflector* CYSFReflectors::find(const std::string& id) { for (std::vector::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) { if (id == (*it)->m_id) return *it; } - LogMessage("Trying to find non existent reflector with an id of %s", id.c_str()); + LogMessage("Trying to find non existent YSF reflector with an id of %s", id.c_str()); return NULL; } -std::vector& CReflectors::current() +std::vector& CYSFReflectors::current() { return m_currReflectors; } -std::vector& CReflectors::search(const std::string& name) +std::vector& CYSFReflectors::search(const std::string& name) { m_search.clear(); @@ -204,7 +204,7 @@ std::vector& CReflectors::search(const std::string& name) return m_search; } -bool CReflectors::reload() +bool CYSFReflectors::reload() { if (m_newReflectors.empty()) return false; @@ -221,7 +221,7 @@ bool CReflectors::reload() return true; } -void CReflectors::clock(unsigned int ms) +void CYSFReflectors::clock(unsigned int ms) { m_timer.clock(ms); diff --git a/YSFGateway/Reflectors.h b/YSFGateway/YSFReflectors.h similarity index 88% rename from YSFGateway/Reflectors.h rename to YSFGateway/YSFReflectors.h index 9ba8cb4..bd5b7a7 100644 --- a/YSFGateway/Reflectors.h +++ b/YSFGateway/YSFReflectors.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(Reflectors_H) -#define Reflectors_H +#if !defined(YSFReflectors_H) +#define YSFReflectors_H #include "UDPSocket.h" #include "Timer.h" @@ -45,10 +45,10 @@ public: unsigned int m_port; }; -class CReflectors { +class CYSFReflectors { public: - CReflectors(const std::string& hostsFile, unsigned int reloadTime); - ~CReflectors(); + CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime); + ~CYSFReflectors(); void setParrot(const std::string& address, unsigned int port); void setYSF2DMR(const std::string& address, unsigned int port); From 05c0cce1db5f09f4a67ca1f0525ea41a70635a32 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 21 Feb 2018 19:46:21 +0000 Subject: [PATCH 02/20] Begin adding FCS specific code. --- YSFGateway/Conf.cpp | 136 ++++++++++++-------- YSFGateway/Conf.h | 61 +++++---- YSFGateway/DTMF.cpp | 27 ++-- YSFGateway/FCSNetwork.cpp | 176 ++++++++++++++++++++++++++ YSFGateway/FCSNetwork.h | 61 +++++++++ YSFGateway/Makefile | 2 +- YSFGateway/Makefile.Solaris | 2 +- YSFGateway/YSFGateway.cpp | 46 ++++--- YSFGateway/YSFGateway.h | 2 + YSFGateway/YSFGateway.ini | 7 +- YSFGateway/YSFGateway.vcxproj | 2 + YSFGateway/YSFGateway.vcxproj.filters | 6 + 12 files changed, 420 insertions(+), 108 deletions(-) create mode 100644 YSFGateway/FCSNetwork.cpp create mode 100644 YSFGateway/FCSNetwork.h diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index eda0178..99eda25 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +32,8 @@ enum SECTION { SECTION_INFO, SECTION_LOG, SECTION_APRS_FI, - SECTION_NETWORK + SECTION_YSF_NETWORK, + SECTION_FCS_NETWORK }; CConf::CConf(const std::string& file) : @@ -61,18 +62,21 @@ m_aprsServer(), m_aprsPort(0U), m_aprsPassword(), m_aprsDescription(), -m_networkEnabled(false), -m_networkPort(0U), -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), -m_networkDebug(false) +m_ysfNetworkEnabled(false), +m_ysfNetworkPort(0U), +m_ysfNetworkHosts(), +m_ysfNetworkReloadTime(0U), +m_ysfNetworkParrotAddress("127.0.0.1"), +m_ysfNetworkParrotPort(0U), +m_ysfNetworkYSF2DMRAddress("127.0.0.1"), +m_ysfNetworkYSF2DMRPort(0U), +m_ysfNetworkStartup(), +m_ysfNetworkInactivityTimeout(0U), +m_ysfNetworkRevert(false), +m_ysfNetworkDebug(false), +m_fcsNetworkEnabled(false), +m_fcsNetworkPort(0U), +m_fcsNetworkDebug(false) { } @@ -102,10 +106,12 @@ bool CConf::read() section = SECTION_INFO; else if (::strncmp(buffer, "[Log]", 5U) == 0) section = SECTION_LOG; - else if (::strncmp(buffer, "[aprs.fi]", 5U) == 0) + else if (::strncmp(buffer, "[aprs.fi]", 9U) == 0) section = SECTION_APRS_FI; - else if (::strncmp(buffer, "[Network]", 5U) == 0) - section = SECTION_NETWORK; + else if (::strncmp(buffer, "[YSF Network]", 13U) == 0) + section = SECTION_YSF_NETWORK; + else if (::strncmp(buffer, "[FCS Network]", 13U) == 0) + section = SECTION_FCS_NETWORK; else section = SECTION_NONE; @@ -175,31 +181,38 @@ bool CConf::read() m_aprsPassword = value; else if (::strcmp(key, "Description") == 0) m_aprsDescription = value; - } else if (section == SECTION_NETWORK) { + } else if (section == SECTION_YSF_NETWORK) { if (::strcmp(key, "Enable") == 0) - m_networkEnabled = ::atoi(value) == 1; + m_ysfNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Port") == 0) - m_networkPort = (unsigned int)::atoi(value); + m_ysfNetworkPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Hosts") == 0) - m_networkHosts = value; + m_ysfNetworkHosts = value; else if (::strcmp(key, "ReloadTime") == 0) - m_networkReloadTime = (unsigned int)::atoi(value); + m_ysfNetworkReloadTime = (unsigned int)::atoi(value); else if (::strcmp(key, "ParrotAddress") == 0) - m_networkParrotAddress = value; + m_ysfNetworkParrotAddress = value; else if (::strcmp(key, "ParrotPort") == 0) - m_networkParrotPort = (unsigned int)::atoi(value); + m_ysfNetworkParrotPort = (unsigned int)::atoi(value); else if (::strcmp(key, "YSF2DMRAddress") == 0) - m_networkYSF2DMRAddress = value; + m_ysfNetworkYSF2DMRAddress = value; else if (::strcmp(key, "YSF2DMRPort") == 0) - m_networkYSF2DMRPort = (unsigned int)::atoi(value); + m_ysfNetworkYSF2DMRPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Startup") == 0) - m_networkStartup = value; + m_ysfNetworkStartup = value; else if (::strcmp(key, "InactivityTimeout") == 0) - m_networkInactivityTimeout = (unsigned int)::atoi(value); + m_ysfNetworkInactivityTimeout = (unsigned int)::atoi(value); else if (::strcmp(key, "Revert") == 0) - m_networkRevert = ::atoi(value) == 1; + m_ysfNetworkRevert = ::atoi(value) == 1; else if (::strcmp(key, "Debug") == 0) - m_networkDebug = ::atoi(value) == 1; + m_ysfNetworkDebug = ::atoi(value) == 1; + } else if (section == SECTION_FCS_NETWORK) { + if (::strcmp(key, "Enable") == 0) + m_fcsNetworkEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Port") == 0) + m_fcsNetworkPort = (unsigned int)::atoi(value); + else if (::strcmp(key, "Debug") == 0) + m_fcsNetworkDebug = ::atoi(value) == 1; } } @@ -328,62 +341,77 @@ std::string CConf::getAPRSDescription() const return m_aprsDescription; } -bool CConf::getNetworkEnabled() const +bool CConf::getYSFNetworkEnabled() const { - return m_networkEnabled; + return m_ysfNetworkEnabled; } -unsigned int CConf::getNetworkPort() const +unsigned int CConf::getYSFNetworkPort() const { - return m_networkPort; + return m_ysfNetworkPort; } -std::string CConf::getNetworkHosts() const +std::string CConf::getYSFNetworkHosts() const { - return m_networkHosts; + return m_ysfNetworkHosts; } -unsigned int CConf::getNetworkReloadTime() const +unsigned int CConf::getYSFNetworkReloadTime() const { - return m_networkReloadTime; + return m_ysfNetworkReloadTime; } -std::string CConf::getNetworkParrotAddress() const +std::string CConf::getYSFNetworkParrotAddress() const { - return m_networkParrotAddress; + return m_ysfNetworkParrotAddress; } -unsigned int CConf::getNetworkParrotPort() const +unsigned int CConf::getYSFNetworkParrotPort() const { - return m_networkParrotPort; + return m_ysfNetworkParrotPort; } -std::string CConf::getNetworkYSF2DMRAddress() const +std::string CConf::getYSFNetworkYSF2DMRAddress() const { - return m_networkYSF2DMRAddress; + return m_ysfNetworkYSF2DMRAddress; } -unsigned int CConf::getNetworkYSF2DMRPort() const +unsigned int CConf::getYSFNetworkYSF2DMRPort() const { - return m_networkYSF2DMRPort; + return m_ysfNetworkYSF2DMRPort; } -std::string CConf::getNetworkStartup() const +std::string CConf::getYSFNetworkStartup() const { - return m_networkStartup; + return m_ysfNetworkStartup; } -unsigned int CConf::getNetworkInactivityTimeout() const +unsigned int CConf::getYSFNetworkInactivityTimeout() const { - return m_networkInactivityTimeout; + return m_ysfNetworkInactivityTimeout; } -bool CConf::getNetworkRevert() const +bool CConf::getYSFNetworkRevert() const { - return m_networkRevert; + return m_ysfNetworkRevert; } -bool CConf::getNetworkDebug() const +bool CConf::getYSFNetworkDebug() const { - return m_networkDebug; + return m_ysfNetworkDebug; +} + +bool CConf::getFCSNetworkEnabled() const +{ + return m_fcsNetworkEnabled; +} + +unsigned int CConf::getFCSNetworkPort() const +{ + return m_fcsNetworkPort; +} + +bool CConf::getFCSNetworkDebug() const +{ + return m_fcsNetworkDebug; } diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 3ea4c0d..716c6dd 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,19 +62,24 @@ public: std::string getAPRSPassword() const; std::string getAPRSDescription() const; - // The Network section - bool getNetworkEnabled() const; - unsigned int getNetworkPort() const; - std::string getNetworkHosts() const; - 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; - bool getNetworkDebug() const; + // The YSF Network section + bool getYSFNetworkEnabled() const; + unsigned int getYSFNetworkPort() const; + std::string getYSFNetworkHosts() const; + unsigned int getYSFNetworkReloadTime() const; + std::string getYSFNetworkParrotAddress() const; + unsigned int getYSFNetworkParrotPort() const; + std::string getYSFNetworkYSF2DMRAddress() const; + unsigned int getYSFNetworkYSF2DMRPort() const; + std::string getYSFNetworkStartup() const; + unsigned int getYSFNetworkInactivityTimeout() const; + bool getYSFNetworkRevert() const; + bool getYSFNetworkDebug() const; + + // The FCS Network section + bool getFCSNetworkEnabled() const; + unsigned int getFCSNetworkPort() const; + bool getFCSNetworkDebug() const; private: std::string m_file; @@ -106,18 +111,22 @@ private: std::string m_aprsPassword; std::string m_aprsDescription; - bool m_networkEnabled; - unsigned int m_networkPort; - std::string m_networkHosts; - 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; - bool m_networkDebug; + bool m_ysfNetworkEnabled; + unsigned int m_ysfNetworkPort; + std::string m_ysfNetworkHosts; + unsigned int m_ysfNetworkReloadTime; + std::string m_ysfNetworkParrotAddress; + unsigned int m_ysfNetworkParrotPort; + std::string m_ysfNetworkYSF2DMRAddress; + unsigned int m_ysfNetworkYSF2DMRPort; + std::string m_ysfNetworkStartup; + unsigned int m_ysfNetworkInactivityTimeout; + bool m_ysfNetworkRevert; + bool m_ysfNetworkDebug; + + bool m_fcsNetworkEnabled; + unsigned int m_fcsNetworkPort; + bool m_fcsNetworkDebug; }; #endif diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index b1658fc..fcc783c 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2017,2018 by Jonathan Naylor G4KLX * Copyright (C) 2011 by DV Developer Group. DJ0ABR * * This program is free software; you can redistribute it and/or modify @@ -160,20 +160,29 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) WX_STATUS CDTMF::validate() const { - if (m_command.length() != 6U) + size_t length = m_command.length(); + if (length != 4U && length != 6U) return WXS_NONE; - if (m_command.at(0U) != '#') + char first = m_command.at(0U); + if (first != '#' && first != 'A') return WXS_NONE; - for (unsigned int i = 1U; i <= 6U; i++) { - if (m_command.at(1U) < '0' || m_command.at(1U) > '9') - return WXS_NONE; + if (length == 4U) { + for (unsigned int i = 1U; i <= 4U; i++) { + if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + return WXS_NONE; + } + } else { + for (unsigned int i = 1U; i <= 6U; i++) { + if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + return WXS_NONE; + } + + if (m_command == "#99999") + return WXS_DISCONNECT; } - if (m_command == "#99999") - return WXS_DISCONNECT; - return WXS_CONNECT; } diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp new file mode 100644 index 0000000..7851de0 --- /dev/null +++ b/YSFGateway/FCSNetwork.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "YSFDefines.h" +#include "FCSNetwork.h" +#include "Utils.h" +#include "Log.h" + +#include +#include +#include + +const unsigned int BUFFER_LENGTH = 200U; + +CFCSNetwork::CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : +m_socket(address, port), +m_debug(debug), +m_address(), +m_port(0U), +m_poll(NULL), +m_unlink(NULL), +m_buffer(1000U, "FCS Network Buffer") +{ + m_poll = new unsigned char[14U]; + ::memcpy(m_poll + 0U, "YSFP", 4U); + + m_unlink = new unsigned char[14U]; + ::memcpy(m_unlink + 0U, "YSFU", 4U); + + std::string node = callsign; + node.resize(YSF_CALLSIGN_LENGTH, ' '); + + for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { + m_poll[i + 4U] = node.at(i); + m_unlink[i + 4U] = node.at(i); + } +} + +CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, bool debug) : +m_socket(port), +m_debug(debug), +m_address(), +m_port(0U), +m_poll(NULL), +m_unlink(NULL), +m_buffer(1000U, "FCS Network Buffer") +{ + m_poll = new unsigned char[14U]; + ::memcpy(m_poll + 0U, "YSFP", 4U); + + m_unlink = new unsigned char[14U]; + ::memcpy(m_unlink + 0U, "YSFU", 4U); + + std::string node = callsign; + node.resize(YSF_CALLSIGN_LENGTH, ' '); + + for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { + m_poll[i + 4U] = node.at(i); + m_unlink[i + 4U] = node.at(i); + } +} + +CFCSNetwork::~CFCSNetwork() +{ + delete[] m_poll; +} + +bool CFCSNetwork::open() +{ + LogMessage("Opening FCS network connection"); + + return m_socket.open(); +} + +void CFCSNetwork::setDestination(const in_addr& address, unsigned int port) +{ + m_address = address; + m_port = port; +} + +void CFCSNetwork::clearDestination() +{ + m_address.s_addr = INADDR_NONE; + m_port = 0U; +} + +bool CFCSNetwork::write(const unsigned char* data) +{ + assert(data != NULL); + + if (m_port == 0U) + return true; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", data, 155U); + + return m_socket.write(data, 155U, m_address, m_port); +} + +bool CFCSNetwork::writePoll() +{ + if (m_port == 0U) + return true; + + return m_socket.write(m_poll, 14U, m_address, m_port); +} + +bool CFCSNetwork::writeUnlink() +{ + if (m_port == 0U) + return true; + + return m_socket.write(m_unlink, 14U, m_address, m_port); +} + +void CFCSNetwork::clock(unsigned int ms) +{ + if (m_port == 0U) + return; + + unsigned char buffer[BUFFER_LENGTH]; + + in_addr address; + unsigned int port; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); + if (length <= 0) + return; + + if (address.s_addr != m_address.s_addr || port != m_port) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Received", buffer, length); + + unsigned char len = length; + m_buffer.addData(&len, 1U); + + m_buffer.addData(buffer, length); +} + +unsigned int CFCSNetwork::read(unsigned char* data) +{ + assert(data != NULL); + + if (m_buffer.isEmpty()) + return 0U; + + unsigned char len = 0U; + m_buffer.getData(&len, 1U); + + m_buffer.getData(data, len); + + return len; +} + +void CFCSNetwork::close() +{ + m_socket.close(); + + LogMessage("Closing FCS network connection"); +} diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h new file mode 100644 index 0000000..aad0f99 --- /dev/null +++ b/YSFGateway/FCSNetwork.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef FCSNetwork_H +#define FCSNetwork_H + +#include "YSFDefines.h" +#include "UDPSocket.h" +#include "RingBuffer.h" + +#include +#include + +class CFCSNetwork { +public: + CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); + CFCSNetwork(unsigned int port, const std::string& callsign, bool debug); + ~CFCSNetwork(); + + bool open(); + + void setDestination(const in_addr& address, unsigned int port); + void clearDestination(); + + bool write(const unsigned char* data); + + bool writePoll(); + bool writeUnlink(); + + unsigned int read(unsigned char* data); + + void clock(unsigned int ms); + + void close(); + +private: + CUDPSocket m_socket; + bool m_debug; + in_addr m_address; + unsigned int m_port; + unsigned char* m_poll; + unsigned char* m_unlink; + CRingBuffer m_buffer; +}; + +#endif diff --git a/YSFGateway/Makefile b/YSFGateway/Makefile index 8e627bd..ad68fce 100644 --- a/YSFGateway/Makefile +++ b/YSFGateway/Makefile @@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/Makefile.Solaris b/YSFGateway/Makefile.Solaris index 2b533ab..dfd7c11 100644 --- a/YSFGateway/Makefile.Solaris +++ b/YSFGateway/Makefile.Solaris @@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread -lsocket LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 5228f4e..8b1a79e 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -82,6 +82,7 @@ m_gps(NULL), m_wiresX(NULL), m_dtmf(NULL), m_ysfNetwork(NULL), +m_fcsNetwork(NULL), m_linked(false), m_exclude(false) { @@ -168,7 +169,7 @@ int CYSFGateway::run() m_callsign = m_conf.getCallsign(); m_suffix = m_conf.getSuffix(); - bool debug = m_conf.getNetworkDebug(); + bool debug = m_conf.getYSFNetworkDebug(); in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); unsigned int rptPort = m_conf.getRptPort(); std::string myAddress = m_conf.getMyAddress(); @@ -184,9 +185,9 @@ int CYSFGateway::run() return 1; } - unsigned int netPort = m_conf.getNetworkPort(); + unsigned int ysfPort = m_conf.getYSFNetworkPort(); - m_ysfNetwork = new CYSFNetwork(netPort, m_callsign, debug); + m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); ret = m_ysfNetwork->open(); if (!ret) { ::LogError("Cannot open the YSF reflector network port"); @@ -194,17 +195,27 @@ int CYSFGateway::run() return 1; } - CTimer inactivityTimer(1000U, m_conf.getNetworkInactivityTimeout() * 60U); + unsigned int fcsPort = m_conf.getFCSNetworkPort(); + + m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, debug); + ret = m_fcsNetwork->open(); + if (!ret) { + ::LogError("Cannot open the FCS reflector network port"); + ::LogFinalise(); + return 1; + } + + CTimer inactivityTimer(1000U, m_conf.getYSFNetworkInactivityTimeout() * 60U); CTimer lostTimer(1000U, 120U); CTimer pollTimer(1000U, 5U); - bool revert = m_conf.getNetworkRevert(); - std::string startup = m_conf.getNetworkStartup(); + bool revert = m_conf.getYSFNetworkRevert(); + std::string startup = m_conf.getYSFNetworkStartup(); - bool networkEnabled = m_conf.getNetworkEnabled(); - if (networkEnabled) { - std::string fileName = m_conf.getNetworkHosts(); - unsigned int reloadTime = m_conf.getNetworkReloadTime(); + bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); + if (ysfNetworkEnabled) { + std::string fileName = m_conf.getYSFNetworkHosts(); + unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime); m_dtmf = new CDTMF; @@ -215,14 +226,14 @@ int CYSFGateway::run() m_wiresX->setInfo(name, txFrequency, rxFrequency); - std::string address = m_conf.getNetworkParrotAddress(); - unsigned int port = m_conf.getNetworkParrotPort(); + std::string address = m_conf.getYSFNetworkParrotAddress(); + unsigned int port = m_conf.getYSFNetworkParrotPort(); if (port > 0U) m_wiresX->setParrot(address, port); - address = m_conf.getNetworkYSF2DMRAddress(); - port = m_conf.getNetworkYSF2DMRPort(); + address = m_conf.getYSFNetworkYSF2DMRAddress(); + port = m_conf.getYSFNetworkYSF2DMRPort(); if (port > 0U) m_wiresX->setYSF2DMR(address, port); @@ -377,7 +388,7 @@ int CYSFGateway::run() m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); } - if (networkEnabled && m_linked && !m_exclude) { + if (ysfNetworkEnabled && m_linked && !m_exclude) { m_ysfNetwork->write(buffer); if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) inactivityTimer.start(); @@ -393,7 +404,7 @@ int CYSFGateway::run() } while (m_ysfNetwork->read(buffer) > 0U) { - if (networkEnabled && m_linked) { + if (ysfNetworkEnabled && m_linked) { // Only pass through YSF data packets if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) rptNetwork.write(buffer); @@ -407,6 +418,7 @@ int CYSFGateway::run() rptNetwork.clock(ms); m_ysfNetwork->clock(ms); + m_fcsNetwork->clock(ms); if (m_gps != NULL) m_gps->clock(ms); if (m_wiresX != NULL) @@ -484,6 +496,7 @@ int CYSFGateway::run() rptNetwork.close(); m_ysfNetwork->close(); + m_fcsNetwork->close(); if (m_gps != NULL) { m_gps->close(); @@ -491,6 +504,7 @@ int CYSFGateway::run() } delete m_ysfNetwork; + delete m_fcsNetwork; delete m_wiresX; delete m_dtmf; diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index f7c320d..fabc41d 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -20,6 +20,7 @@ #define YSFGateway_H #include "YSFNetwork.h" +#include "FCSNetwork.h" #include "WiresX.h" #include "Conf.h" #include "DTMF.h" @@ -43,6 +44,7 @@ private: CWiresX* m_wiresX; CDTMF* m_dtmf; CYSFNetwork* m_ysfNetwork; + CFCSNetwork* m_fcsNetwork; bool m_linked; bool m_exclude; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index f8ccab5..c81d485 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -33,7 +33,7 @@ Port=14580 Password=9999 Description=APRS Description -[Network] +[YSF Network] Enable=1 Port=42000 Hosts=./YSFHosts.txt @@ -46,3 +46,8 @@ YSF2DMRPort=42013 InactivityTimeout=10 # Revert=0 Debug=0 + +[FCS Network] +Enable=1 +Port=42000 +Debug=0 diff --git a/YSFGateway/YSFGateway.vcxproj b/YSFGateway/YSFGateway.vcxproj index 521ef68..df351b7 100644 --- a/YSFGateway/YSFGateway.vcxproj +++ b/YSFGateway/YSFGateway.vcxproj @@ -151,6 +151,7 @@ + @@ -178,6 +179,7 @@ + diff --git a/YSFGateway/YSFGateway.vcxproj.filters b/YSFGateway/YSFGateway.vcxproj.filters index 9065e58..246f020 100644 --- a/YSFGateway/YSFGateway.vcxproj.filters +++ b/YSFGateway/YSFGateway.vcxproj.filters @@ -86,6 +86,9 @@ Header Files + + Header Files + @@ -154,5 +157,8 @@ Source Files + + Source Files + \ No newline at end of file From 9dc484ea64dd86ba8be15632c4876152ac093d08 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 21 Feb 2018 20:27:11 +0000 Subject: [PATCH 03/20] Start splitting YSF and FCS functionality. --- YSFGateway/DTMF.cpp | 6 +- YSFGateway/WiresX.cpp | 2 +- YSFGateway/WiresX.h | 3 +- YSFGateway/YSFGateway.cpp | 306 +++++++++++++++++++++----------------- YSFGateway/YSFGateway.h | 16 +- 5 files changed, 190 insertions(+), 143 deletions(-) diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index fcc783c..c475f41 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -173,6 +173,8 @@ WX_STATUS CDTMF::validate() const if (m_command.at(1U) < '0' || m_command.at(1U) > '9') return WXS_NONE; } + + return WXS_CONNECT_FCS; } else { for (unsigned int i = 1U; i <= 6U; i++) { if (m_command.at(1U) < '0' || m_command.at(1U) > '9') @@ -181,9 +183,9 @@ WX_STATUS CDTMF::validate() const if (m_command == "#99999") return WXS_DISCONNECT; - } - return WXS_CONNECT; + return WXS_CONNECT_YSF; + } } std::string CDTMF::getReflector() diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 72d9c4f..dce4b25 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -294,7 +294,7 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch m_status = WXSI_CONNECT; m_timer.start(); - return WXS_CONNECT; + return WXS_CONNECT_YSF; } void CWiresX::processConnect(CYSFReflector* reflector) diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index 847e858..e1128cf 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -27,7 +27,8 @@ enum WX_STATUS { WXS_NONE, - WXS_CONNECT, + WXS_CONNECT_YSF, + WXS_CONNECT_FCS, WXS_DISCONNECT }; diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 8b1a79e..168572f 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -80,11 +80,14 @@ m_suffix(), m_conf(configFile), m_gps(NULL), m_wiresX(NULL), -m_dtmf(NULL), +m_dtmf(), m_ysfNetwork(NULL), m_fcsNetwork(NULL), -m_linked(false), -m_exclude(false) +m_linkType(LINK_NONE), +m_exclude(false), +m_inactivityTimer(1000U), +m_lostTimer(1000U, 120U), +m_ysfPollTimer(1000U, 5U) { } @@ -205,20 +208,18 @@ int CYSFGateway::run() return 1; } - CTimer inactivityTimer(1000U, m_conf.getYSFNetworkInactivityTimeout() * 60U); - CTimer lostTimer(1000U, 120U); - CTimer pollTimer(1000U, 5U); + m_inactivityTimer.setTimeout(m_conf.getYSFNetworkInactivityTimeout() * 60U); bool revert = m_conf.getYSFNetworkRevert(); std::string startup = m_conf.getYSFNetworkStartup(); + bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); if (ysfNetworkEnabled) { std::string fileName = m_conf.getYSFNetworkHosts(); unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime); - m_dtmf = new CDTMF; std::string name = m_conf.getName(); unsigned int txFrequency = m_conf.getTxFrequency(); @@ -251,12 +252,12 @@ int CYSFGateway::run() m_ysfNetwork->writePoll(); if (!revert) - inactivityTimer.start(); + m_inactivityTimer.start(); - lostTimer.start(); - pollTimer.start(); + m_lostTimer.start(); + m_ysfPollTimer.start(); - m_linked = true; + m_linkType = LINK_YSF; } } } @@ -283,133 +284,52 @@ int CYSFGateway::run() // Don't send out control data m_exclude = (dt == YSF_DT_DATA_FR_MODE); - if (m_wiresX != NULL) { - WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); - switch (status) { - case WXS_CONNECT: { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + if (m_wiresX != NULL) + processWiresX(buffer, fi, dt, fn, ft); - CYSFReflector* reflector = m_wiresX->getReflector(); - LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - - inactivityTimer.start(); - lostTimer.start(); - pollTimer.start(); - - m_linked = true; - } - break; - case WXS_DISCONNECT: - LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->clearDestination(); - - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; - break; - default: - break; - } - - status = WXS_NONE; - switch (dt) { - case YSF_DT_VD_MODE2: - status = m_dtmf->decodeVDMode2(buffer + 35U, (buffer[34U] & 0x01U) == 0x01U); - break; - default: - break; - } - - switch (status) { - case WXS_CONNECT: { - std::string id = m_dtmf->getReflector(); - CYSFReflector* reflector = m_wiresX->getReflector(id); - if (reflector != NULL) { - m_wiresX->processConnect(reflector); - - if (m_linked) { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - } - - LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - - inactivityTimer.start(); - lostTimer.start(); - pollTimer.start(); - - m_linked = true; - } - } - break; - case WXS_DISCONNECT: - if (m_linked) { - m_wiresX->processDisconnect(); - - LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); - - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->clearDestination(); - - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; - } - break; - default: - break; - } - } + processDTMF(buffer, dt); if (m_gps != NULL) m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); } - if (ysfNetworkEnabled && m_linked && !m_exclude) { + if (ysfNetworkEnabled && m_linkType == LINK_YSF && !m_exclude) { m_ysfNetwork->write(buffer); if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) - inactivityTimer.start(); + m_inactivityTimer.start(); + } + + if (fcsNetworkEnabled && m_linkType == LINK_FCS && !m_exclude) { + m_fcsNetwork->write(buffer); + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + m_inactivityTimer.start(); } if ((buffer[34U] & 0x01U) == 0x01U) { if (m_gps != NULL) m_gps->reset(); - if (m_dtmf != NULL) - m_dtmf->reset(); + m_dtmf.reset(); m_exclude = false; } } while (m_ysfNetwork->read(buffer) > 0U) { - if (ysfNetworkEnabled && m_linked) { + if (ysfNetworkEnabled && m_linkType == LINK_YSF) { // Only pass through YSF data packets if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) rptNetwork.write(buffer); - lostTimer.start(); + m_lostTimer.start(); + } + } + + while (m_fcsNetwork->read(buffer) > 0U) { + if (fcsNetworkEnabled && m_linkType == LINK_FCS) { + // Only pass through YSF data packets + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + rptNetwork.write(buffer); + + m_lostTimer.start(); } } @@ -424,9 +344,9 @@ int CYSFGateway::run() if (m_wiresX != NULL) m_wiresX->clock(ms); - inactivityTimer.clock(ms); - if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) { - if (m_linked) { + m_inactivityTimer.clock(ms); + if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { + if (m_linkType == LINK_YSF) { CYSFReflector* reflector = NULL; if (revert && !startup.empty() && m_wiresX != NULL) reflector = m_wiresX->getReflector(startup); @@ -434,7 +354,8 @@ int CYSFGateway::run() if (reflector != NULL) { LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - m_wiresX->processConnect(reflector); + if (m_wiresX != NULL) + m_wiresX->processConnect(reflector); m_ysfNetwork->writeUnlink(); m_ysfNetwork->writeUnlink(); @@ -445,8 +366,8 @@ int CYSFGateway::run() m_ysfNetwork->writePoll(); m_ysfNetwork->writePoll(); - lostTimer.start(); - pollTimer.start(); + m_lostTimer.start(); + m_ysfPollTimer.start(); } else { LogMessage("Disconnecting due to inactivity"); @@ -458,36 +379,37 @@ int CYSFGateway::run() m_ysfNetwork->writeUnlink(); m_ysfNetwork->clearDestination(); - lostTimer.stop(); - pollTimer.stop(); + m_lostTimer.stop(); + m_ysfPollTimer.stop(); - m_linked = false; + m_linkType = LINK_NONE; } } - inactivityTimer.stop(); + m_inactivityTimer.stop(); } - lostTimer.clock(ms); - if (lostTimer.isRunning() && lostTimer.hasExpired()) { + m_lostTimer.clock(ms); + if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) { LogWarning("Link has failed, polls lost"); if (m_wiresX != NULL) m_wiresX->processDisconnect(); - m_ysfNetwork->clearDestination(); + if (m_ysfNetwork != NULL) + m_ysfNetwork->clearDestination(); - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_ysfPollTimer.stop(); - m_linked = false; + m_linkType = LINK_NONE; } - pollTimer.clock(ms); - if (pollTimer.isRunning() && pollTimer.hasExpired()) { + m_ysfPollTimer.clock(ms); + if (m_ysfPollTimer.isRunning() && m_ysfPollTimer.hasExpired()) { m_ysfNetwork->writePoll(); - pollTimer.start(); + m_ysfPollTimer.start(); } if (ms < 5U) @@ -506,7 +428,6 @@ int CYSFGateway::run() delete m_ysfNetwork; delete m_fcsNetwork; delete m_wiresX; - delete m_dtmf; ::LogFinalise(); @@ -539,3 +460,114 @@ void CYSFGateway::createGPS() m_gps = NULL; } } + +void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft) +{ + assert(buffer != NULL); + + WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); + switch (status) { + case WXS_CONNECT_YSF: { + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + + CYSFReflector* reflector = m_wiresX->getReflector(); + LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); + + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + + m_inactivityTimer.start(); + m_lostTimer.start(); + m_ysfPollTimer.start(); + + m_linkType = LINK_YSF; + } + break; + case WXS_DISCONNECT: + LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); + + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_ysfPollTimer.stop(); + + m_linkType = LINK_NONE; + break; + default: + break; + } +} + +void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) +{ + assert(buffer != NULL); + + WX_STATUS status = WXS_NONE; + switch (dt) { + case YSF_DT_VD_MODE2: + status = m_dtmf.decodeVDMode2(buffer + 35U, (buffer[34U] & 0x01U) == 0x01U); + break; + default: + break; + } + + switch (status) { + case WXS_CONNECT_YSF: { + std::string id = m_dtmf.getReflector(); + CYSFReflector* reflector = m_wiresX->getReflector(id); + if (reflector != NULL) { + if (m_wiresX != NULL) + m_wiresX->processConnect(reflector); + + if (m_linkType == LINK_YSF) { + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + } + + LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); + + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(); + + m_inactivityTimer.start(); + m_lostTimer.start(); + m_ysfPollTimer.start(); + + m_linkType = LINK_YSF; + } + } + break; + case WXS_DISCONNECT: + if (m_linkType == LINK_YSF) { + if (m_wiresX != NULL) + m_wiresX->processDisconnect(); + + LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); + + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); + + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_ysfPollTimer.stop(); + + m_linkType = LINK_NONE; + } + break; + default: + break; + } +} diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index fabc41d..1aebf76 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -22,12 +22,19 @@ #include "YSFNetwork.h" #include "FCSNetwork.h" #include "WiresX.h" +#include "Timer.h" #include "Conf.h" #include "DTMF.h" #include "GPS.h" #include +enum LINK_TYPE { + LINK_NONE, + LINK_YSF, + LINK_FCS +}; + class CYSFGateway { public: @@ -42,12 +49,17 @@ private: CConf m_conf; CGPS* m_gps; CWiresX* m_wiresX; - CDTMF* m_dtmf; + CDTMF m_dtmf; CYSFNetwork* m_ysfNetwork; CFCSNetwork* m_fcsNetwork; - bool m_linked; + LINK_TYPE m_linkType; bool m_exclude; + CTimer m_inactivityTimer; + CTimer m_lostTimer; + CTimer m_ysfPollTimer; + void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); + void processDTMF(const unsigned char* buffer, unsigned char dt); void createGPS(); }; From a52d831ba5901717cc28ca8cdc454220101409cc Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 21 Feb 2018 21:53:58 +0000 Subject: [PATCH 04/20] Add the FCS protocol and the beginnings of the control for it. --- YSFGateway/Conf.cpp | 18 ++++++- YSFGateway/Conf.h | 4 ++ YSFGateway/DTMF.cpp | 11 +++- YSFGateway/FCSNetwork.cpp | 104 +++++++++++++++++++------------------- YSFGateway/FCSNetwork.h | 13 +++-- YSFGateway/YSFGateway.cpp | 79 +++++++++++++++++++++-------- YSFGateway/YSFGateway.ini | 2 + 7 files changed, 149 insertions(+), 82 deletions(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 99eda25..01e9f8a 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -40,6 +40,7 @@ CConf::CConf(const std::string& file) : m_file(file), m_callsign(), m_suffix(), +m_id(0U), m_rptAddress(), m_rptPort(0U), m_myAddress(), @@ -50,6 +51,7 @@ m_txFrequency(0U), m_power(0U), m_latitude(0.0F), m_longitude(0.0F), +m_locator(), m_height(0), m_name(), m_description(), @@ -134,7 +136,9 @@ bool CConf::read() for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); m_suffix = value; - } else if (::strcmp(key, "RptAddress") == 0) + } else if (::strcmp(key, "Id") == 0) + m_id = (unsigned int)::atoi(value); + else if (::strcmp(key, "RptAddress") == 0) m_rptAddress = value; else if (::strcmp(key, "RptPort") == 0) m_rptPort = (unsigned int)::atoi(value); @@ -155,6 +159,8 @@ bool CConf::read() m_latitude = float(::atof(value)); else if (::strcmp(key, "Longitude") == 0) m_longitude = float(::atof(value)); + else if (::strcmp(key, "Locator") == 0) + m_locator = value; else if (::strcmp(key, "Height") == 0) m_height = ::atoi(value); else if (::strcmp(key, "Name") == 0) @@ -231,6 +237,11 @@ std::string CConf::getSuffix() const return m_suffix; } +unsigned int CConf::getId() const +{ + return m_id; +} + std::string CConf::getRptAddress() const { return m_rptAddress; @@ -281,6 +292,11 @@ float CConf::getLongitude() const return m_longitude; } +std::string CConf::getLocator() const +{ + return m_locator; +} + int CConf::getHeight() const { return m_height; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 716c6dd..1c05cb8 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -33,6 +33,7 @@ public: // The General section std::string getCallsign() const; std::string getSuffix() const; + unsigned int getId() const; std::string getRptAddress() const; unsigned int getRptPort() const; std::string getMyAddress() const; @@ -45,6 +46,7 @@ public: unsigned int getPower() const; float getLatitude() const; float getLongitude() const; + std::string getLocator() const; int getHeight() const; std::string getName() const; std::string getDescription() const; @@ -85,6 +87,7 @@ private: std::string m_file; std::string m_callsign; std::string m_suffix; + unsigned int m_id; std::string m_rptAddress; unsigned int m_rptPort; std::string m_myAddress; @@ -96,6 +99,7 @@ private: unsigned int m_power; float m_latitude; float m_longitude; + std::string m_locator; int m_height; std::string m_name; std::string m_description; diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index c475f41..de30b72 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -161,14 +161,21 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) WX_STATUS CDTMF::validate() const { size_t length = m_command.length(); - if (length != 4U && length != 6U) + if (length != 3U && length != 4U && length != 6U) return WXS_NONE; char first = m_command.at(0U); if (first != '#' && first != 'A') return WXS_NONE; - if (length == 4U) { + if (length == 3U) { + for (unsigned int i = 1U; i <= 3U; i++) { + if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + return WXS_NONE; + } + + return WXS_CONNECT_FCS; + } else if (length == 4U) { for (unsigned int i = 1U; i <= 4U; i++) { if (m_command.at(1U) < '0' || m_command.at(1U) > '9') return WXS_NONE; diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 7851de0..ec90975 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -25,59 +25,31 @@ #include #include +const char* FCS_VERSION = "MMDVM v.01"; + const unsigned int BUFFER_LENGTH = 200U; -CFCSNetwork::CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : -m_socket(address, port), -m_debug(debug), -m_address(), -m_port(0U), -m_poll(NULL), -m_unlink(NULL), -m_buffer(1000U, "FCS Network Buffer") -{ - m_poll = new unsigned char[14U]; - ::memcpy(m_poll + 0U, "YSFP", 4U); - - m_unlink = new unsigned char[14U]; - ::memcpy(m_unlink + 0U, "YSFU", 4U); - - std::string node = callsign; - node.resize(YSF_CALLSIGN_LENGTH, ' '); - - for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { - m_poll[i + 4U] = node.at(i); - m_unlink[i + 4U] = node.at(i); - } -} - -CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, bool debug) : +CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug) : m_socket(port), m_debug(debug), m_address(), m_port(0U), -m_poll(NULL), -m_unlink(NULL), +m_info(NULL), +m_callsign(callsign), +m_reflector(), m_buffer(1000U, "FCS Network Buffer") { - m_poll = new unsigned char[14U]; - ::memcpy(m_poll + 0U, "YSFP", 4U); + m_info = new unsigned char[100U]; + ::memset(m_info, ' ', 100U); - m_unlink = new unsigned char[14U]; - ::memcpy(m_unlink + 0U, "YSFU", 4U); + m_callsign.resize(6U, ' '); - std::string node = callsign; - node.resize(YSF_CALLSIGN_LENGTH, ' '); - - for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { - m_poll[i + 4U] = node.at(i); - m_unlink[i + 4U] = node.at(i); - } + ::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); } CFCSNetwork::~CFCSNetwork() { - delete[] m_poll; + delete[] m_info; } bool CFCSNetwork::open() @@ -106,18 +78,35 @@ bool CFCSNetwork::write(const unsigned char* data) if (m_port == 0U) return true; - if (m_debug) - CUtils::dump(1U, "FCS Network Data Sent", data, 155U); + unsigned char buffer[130U]; + ::memset(buffer + 0U, ' ', 130U); + ::memcpy(buffer + 0U, data + 35U, 120U); + ::memcpy(buffer + 121U, m_reflector.c_str(), 8U); - return m_socket.write(data, 155U, m_address, m_port); + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", buffer, 130U); + + return m_socket.write(buffer, 130U, m_address, m_port); } -bool CFCSNetwork::writePoll() +bool CFCSNetwork::writeLink(const std::string& reflector) { if (m_port == 0U) return true; - return m_socket.write(m_poll, 14U, m_address, m_port); + m_reflector = reflector; + m_reflector.resize(8U, ' '); + + unsigned char buffer[25U]; + ::memset(buffer + 0U, ' ', 25U); + ::memcpy(buffer + 0U, "PING", 4U); + ::memcpy(buffer + 4U, m_callsign.c_str(), 6U); + ::memcpy(buffer + 10U, m_reflector.c_str(), 6U); + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", buffer, 25U); + + return m_socket.write(buffer, 25U, m_address, m_port); } bool CFCSNetwork::writeUnlink() @@ -125,7 +114,7 @@ bool CFCSNetwork::writeUnlink() if (m_port == 0U) return true; - return m_socket.write(m_unlink, 14U, m_address, m_port); + return m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port); } void CFCSNetwork::clock(unsigned int ms) @@ -147,10 +136,11 @@ void CFCSNetwork::clock(unsigned int ms) if (m_debug) CUtils::dump(1U, "FCS Network Data Received", buffer, length); - unsigned char len = length; - m_buffer.addData(&len, 1U); + if (length == 7 || length == 10) + writeInfo(); - m_buffer.addData(buffer, length); + if (length == 130) + m_buffer.addData(buffer, 130U); } unsigned int CFCSNetwork::read(unsigned char* data) @@ -160,12 +150,9 @@ unsigned int CFCSNetwork::read(unsigned char* data) if (m_buffer.isEmpty()) return 0U; - unsigned char len = 0U; - m_buffer.getData(&len, 1U); + m_buffer.getData(data, 130U); - m_buffer.getData(data, len); - - return len; + return 155U; } void CFCSNetwork::close() @@ -174,3 +161,14 @@ void CFCSNetwork::close() LogMessage("Closing FCS network connection"); } + +void CFCSNetwork::writeInfo() +{ + if (m_port == 0U) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U); + + m_socket.write(m_info, 100U, m_address, m_port); +} diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index aad0f99..3d89d20 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -28,8 +28,7 @@ class CFCSNetwork { public: - CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); - CFCSNetwork(unsigned int port, const std::string& callsign, bool debug); + CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug); ~CFCSNetwork(); bool open(); @@ -39,7 +38,8 @@ public: bool write(const unsigned char* data); - bool writePoll(); + bool writeLink(const std::string& reflector); + bool writeUnlink(); unsigned int read(unsigned char* data); @@ -53,9 +53,12 @@ private: bool m_debug; in_addr m_address; unsigned int m_port; - unsigned char* m_poll; - unsigned char* m_unlink; + unsigned char* m_info; + std::string m_callsign; + std::string m_reflector; CRingBuffer m_buffer; + + void writeInfo(); }; #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 168572f..01c942d 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -198,9 +198,14 @@ int CYSFGateway::run() return 1; } + unsigned int txFrequency = m_conf.getTxFrequency(); + unsigned int rxFrequency = m_conf.getRxFrequency(); + std::string locator = m_conf.getLocator(); + unsigned int id = m_conf.getId(); + unsigned int fcsPort = m_conf.getFCSNetworkPort(); - m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, debug); + m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug); ret = m_fcsNetwork->open(); if (!ret) { ::LogError("Cannot open the FCS reflector network port"); @@ -222,8 +227,6 @@ int CYSFGateway::run() m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime); std::string name = m_conf.getName(); - unsigned int txFrequency = m_conf.getTxFrequency(); - unsigned int rxFrequency = m_conf.getRxFrequency(); m_wiresX->setInfo(name, txFrequency, rxFrequency); @@ -300,9 +303,10 @@ int CYSFGateway::run() } if (fcsNetworkEnabled && m_linkType == LINK_FCS && !m_exclude) { - m_fcsNetwork->write(buffer); - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) { + m_fcsNetwork->write(buffer); m_inactivityTimer.start(); + } } if ((buffer[34U] & 0x01U) == 0x01U) { @@ -325,10 +329,7 @@ int CYSFGateway::run() while (m_fcsNetwork->read(buffer) > 0U) { if (fcsNetworkEnabled && m_linkType == LINK_FCS) { - // Only pass through YSF data packets - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) - rptNetwork.write(buffer); - + rptNetwork.write(buffer); m_lostTimer.start(); } } @@ -468,9 +469,17 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); switch (status) { case WXS_CONNECT_YSF: { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + if (m_linkType == LINK_YSF) { + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + } + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->clearDestination(); + } CYSFReflector* reflector = m_wiresX->getReflector(); LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); @@ -488,18 +497,33 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u } break; case WXS_DISCONNECT: - LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + if (m_linkType == LINK_YSF) { + LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->clearDestination(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); - m_inactivityTimer.stop(); - m_lostTimer.stop(); - m_ysfPollTimer.stop(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_ysfPollTimer.stop(); - m_linkType = LINK_NONE; + m_linkType = LINK_NONE; + } + if (m_linkType == LINK_FCS) { + LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->clearDestination(); + + m_inactivityTimer.stop(); + m_lostTimer.stop(); + + m_linkType = LINK_NONE; + } break; default: break; @@ -566,6 +590,19 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) m_linkType = LINK_NONE; } + if (m_linkType == LINK_FCS) { + LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); + + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->clearDestination(); + + m_inactivityTimer.stop(); + m_lostTimer.stop(); + + m_linkType = LINK_NONE; + } break; default: break; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index c81d485..85d6d42 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -2,6 +2,7 @@ Callsign=G9BF Suffix=RPT # Suffix=ND +Id=1234567 RptAddress=127.0.0.1 RptPort=3200 LocalAddress=127.0.0.1 @@ -14,6 +15,7 @@ TXFrequency=439475000 Power=1 Latitude=0.0 Longitude=0.0 +Locator=IO90TT Height=0 Name=Nowhere Description=Multi-Mode Repeater From 295677878eb7539ffe1ede2f7c9a5ea350552418 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 07:37:29 +0000 Subject: [PATCH 05/20] Still need to handle polls and such like. --- YSFGateway/FCSNetwork.cpp | 24 +++++++++++++++-------- YSFGateway/FCSNetwork.h | 19 +++++++++--------- YSFGateway/YSFDefines.h | 4 +++- YSFGateway/YSFGateway.cpp | 41 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 18 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index ec90975..e0ee7d6 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -54,17 +54,16 @@ CFCSNetwork::~CFCSNetwork() bool CFCSNetwork::open() { + m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net"); + m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net"); + m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net"); + m_addresses["FCS004"] = CUDPSocket::lookup("fcs004.xreflector.net"); + LogMessage("Opening FCS network connection"); return m_socket.open(); } -void CFCSNetwork::setDestination(const in_addr& address, unsigned int port) -{ - m_address = address; - m_port = port; -} - void CFCSNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; @@ -91,8 +90,17 @@ bool CFCSNetwork::write(const unsigned char* data) bool CFCSNetwork::writeLink(const std::string& reflector) { - if (m_port == 0U) - return true; + m_port = 0U; + + if (m_addresses.count(reflector) == 0U) + return false; + + m_address = m_addresses[reflector]; + + if (m_address.s_addr == INADDR_NONE) + return false; + + m_port = FCS_PORT; m_reflector = reflector; m_reflector.resize(8U, ' '); diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 3d89d20..836c462 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -25,6 +25,7 @@ #include #include +#include class CFCSNetwork { public: @@ -33,7 +34,6 @@ public: bool open(); - void setDestination(const in_addr& address, unsigned int port); void clearDestination(); bool write(const unsigned char* data); @@ -49,14 +49,15 @@ public: void close(); private: - CUDPSocket m_socket; - bool m_debug; - in_addr m_address; - unsigned int m_port; - unsigned char* m_info; - std::string m_callsign; - std::string m_reflector; - CRingBuffer m_buffer; + CUDPSocket m_socket; + bool m_debug; + in_addr m_address; + unsigned int m_port; + unsigned char* m_info; + std::string m_callsign; + std::string m_reflector; + CRingBuffer m_buffer; + std::map m_addresses; void writeInfo(); }; diff --git a/YSFGateway/YSFDefines.h b/YSFGateway/YSFDefines.h index 2e75625..b2aefc6 100644 --- a/YSFGateway/YSFDefines.h +++ b/YSFGateway/YSFDefines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,4 +47,6 @@ const unsigned char YSF_CM_INDIVIDUAL = 0x03U; const unsigned char YSF_MR_NOT_BUSY = 0x01U; const unsigned char YSF_MR_BUSY = 0x02U; +const unsigned int FCS_PORT = 62500U; + #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 01c942d..6db2dc2 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -397,6 +397,9 @@ int CYSFGateway::run() if (m_wiresX != NULL) m_wiresX->processDisconnect(); + if (m_fcsNetwork != NULL) + m_fcsNetwork->clearDestination(); + if (m_ysfNetwork != NULL) m_ysfNetwork->clearDestination(); @@ -556,6 +559,12 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) m_ysfNetwork->writeUnlink(); m_ysfNetwork->writeUnlink(); } + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->clearDestination(); + } LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); @@ -572,6 +581,38 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) } } break; + case WXS_CONNECT_FCS: { + std::string id = m_dtmf.getReflector(); + if (id.length() == 2U) + id = "FCS00" + id.at(0U) + std::string("0") + id.at(1U); + else + id = "FCS00" + id.at(0U) + id.at(1U) + id.at(2U); + + if (m_linkType == LINK_YSF) { + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(); + m_ysfNetwork->clearDestination(); + m_ysfPollTimer.stop(); + } + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(); + } + + LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U); + + m_fcsNetwork->writeLink(id); + m_fcsNetwork->writeLink(id); + m_fcsNetwork->writeLink(id); + + m_inactivityTimer.start(); + m_lostTimer.start(); + + m_linkType = LINK_FCS; + } + break; case WXS_DISCONNECT: if (m_linkType == LINK_YSF) { if (m_wiresX != NULL) From 4edd2ebdd19876a8ecd4ea651d7c5bcc29165dac Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 08:05:21 +0000 Subject: [PATCH 06/20] Still need to handle polls. --- YSFGateway/FCSNetwork.cpp | 34 +++++++++++++++++++++++----------- YSFGateway/FCSNetwork.h | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index e0ee7d6..7b8cb70 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -37,7 +37,8 @@ m_port(0U), m_info(NULL), m_callsign(callsign), m_reflector(), -m_buffer(1000U, "FCS Network Buffer") +m_buffer(1000U, "FCS Network Buffer"), +m_n(0U) { m_info = new unsigned char[100U]; ::memset(m_info, ' ', 100U); @@ -54,6 +55,8 @@ CFCSNetwork::~CFCSNetwork() bool CFCSNetwork::open() { + LogMessage("Resolving FCS00x addresses"); + m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net"); m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net"); m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net"); @@ -90,15 +93,19 @@ bool CFCSNetwork::write(const unsigned char* data) bool CFCSNetwork::writeLink(const std::string& reflector) { - m_port = 0U; + if (m_port == 0U) { + std::string name = reflector.substr(0U, 6U); + if (m_addresses.count(name) == 0U) { + LogError("Unknown FCS reflector - %s", name.c_str()); + return false; + } - if (m_addresses.count(reflector) == 0U) - return false; - - m_address = m_addresses[reflector]; - - if (m_address.s_addr == INADDR_NONE) - return false; + m_address = m_addresses[name]; + if (m_address.s_addr == INADDR_NONE) { + LogError("FCS reflector %s has no address", name.c_str()); + return false; + } + } m_port = FCS_PORT; @@ -148,7 +155,7 @@ void CFCSNetwork::clock(unsigned int ms) writeInfo(); if (length == 130) - m_buffer.addData(buffer, 130U); + m_buffer.addData(buffer, 120U); } unsigned int CFCSNetwork::read(unsigned char* data) @@ -158,7 +165,12 @@ unsigned int CFCSNetwork::read(unsigned char* data) if (m_buffer.isEmpty()) return 0U; - m_buffer.getData(data, 130U); + ::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U); + + m_buffer.getData(data + 35U, 120U); + + data[34U] = m_n; + m_n += 2U; return 155U; } diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 836c462..bf6d610 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -58,6 +58,7 @@ private: std::string m_reflector; CRingBuffer m_buffer; std::map m_addresses; + unsigned char m_n; void writeInfo(); }; From 9719b1d2694030e348d32ff85a022bd1f6acfe3e Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 19:11:21 +0000 Subject: [PATCH 07/20] Lots of small changes. --- YSFGateway/Conf.cpp | 8 --- YSFGateway/Conf.h | 2 - YSFGateway/FCSNetwork.cpp | 75 ++++++++++--------- YSFGateway/FCSNetwork.h | 9 +-- YSFGateway/YSFGateway.cpp | 148 +++++++++++++++++++------------------- YSFGateway/YSFGateway.h | 2 +- YSFGateway/YSFGateway.ini | 1 - YSFGateway/YSFNetwork.cpp | 58 +++++++++------ YSFGateway/YSFNetwork.h | 8 ++- 9 files changed, 163 insertions(+), 148 deletions(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 01e9f8a..90ee901 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -51,7 +51,6 @@ m_txFrequency(0U), m_power(0U), m_latitude(0.0F), m_longitude(0.0F), -m_locator(), m_height(0), m_name(), m_description(), @@ -159,8 +158,6 @@ bool CConf::read() m_latitude = float(::atof(value)); else if (::strcmp(key, "Longitude") == 0) m_longitude = float(::atof(value)); - else if (::strcmp(key, "Locator") == 0) - m_locator = value; else if (::strcmp(key, "Height") == 0) m_height = ::atoi(value); else if (::strcmp(key, "Name") == 0) @@ -292,11 +289,6 @@ float CConf::getLongitude() const return m_longitude; } -std::string CConf::getLocator() const -{ - return m_locator; -} - int CConf::getHeight() const { return m_height; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 1c05cb8..01e20af 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -46,7 +46,6 @@ public: unsigned int getPower() const; float getLatitude() const; float getLongitude() const; - std::string getLocator() const; int getHeight() const; std::string getName() const; std::string getDescription() const; @@ -99,7 +98,6 @@ private: unsigned int m_power; float m_latitude; float m_longitude; - std::string m_locator; int m_height; std::string m_name; std::string m_description; diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 7b8cb70..4923205 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -34,23 +34,23 @@ m_socket(port), m_debug(debug), m_address(), m_port(0U), +m_ping(NULL), m_info(NULL), -m_callsign(callsign), m_reflector(), m_buffer(1000U, "FCS Network Buffer"), m_n(0U) { m_info = new unsigned char[100U]; - ::memset(m_info, ' ', 100U); - - m_callsign.resize(6U, ' '); - ::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); + + m_ping = new unsigned char[25U]; + ::sprintf((char*)m_ping, "PING%6.6s ", callsign.c_str()); } CFCSNetwork::~CFCSNetwork() { delete[] m_info; + delete[] m_ping; } bool CFCSNetwork::open() @@ -73,12 +73,12 @@ void CFCSNetwork::clearDestination() m_port = 0U; } -bool CFCSNetwork::write(const unsigned char* data) +void CFCSNetwork::write(const unsigned char* data) { assert(data != NULL); if (m_port == 0U) - return true; + return; unsigned char buffer[130U]; ::memset(buffer + 0U, ' ', 130U); @@ -88,55 +88,45 @@ bool CFCSNetwork::write(const unsigned char* data) if (m_debug) CUtils::dump(1U, "FCS Network Data Sent", buffer, 130U); - return m_socket.write(buffer, 130U, m_address, m_port); + m_socket.write(buffer, 130U, m_address, m_port); } -bool CFCSNetwork::writeLink(const std::string& reflector) +void CFCSNetwork::writeLink(const std::string& reflector) { if (m_port == 0U) { std::string name = reflector.substr(0U, 6U); if (m_addresses.count(name) == 0U) { LogError("Unknown FCS reflector - %s", name.c_str()); - return false; + return; } m_address = m_addresses[name]; if (m_address.s_addr == INADDR_NONE) { LogError("FCS reflector %s has no address", name.c_str()); - return false; + return; } } m_port = FCS_PORT; m_reflector = reflector; - m_reflector.resize(8U, ' '); - unsigned char buffer[25U]; - ::memset(buffer + 0U, ' ', 25U); - ::memcpy(buffer + 0U, "PING", 4U); - ::memcpy(buffer + 4U, m_callsign.c_str(), 6U); - ::memcpy(buffer + 10U, m_reflector.c_str(), 6U); + ::memcpy(m_ping + 10U, m_reflector.c_str(), 8U); - if (m_debug) - CUtils::dump(1U, "FCS Network Data Sent", buffer, 25U); - - return m_socket.write(buffer, 25U, m_address, m_port); + writePing(); } -bool CFCSNetwork::writeUnlink() -{ - if (m_port == 0U) - return true; - - return m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port); -} - -void CFCSNetwork::clock(unsigned int ms) +void CFCSNetwork::writeUnlink(unsigned int count) { if (m_port == 0U) return; + for (unsigned int i = 0U; i < count; i++) + m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port); +} + +void CFCSNetwork::clock(unsigned int ms) +{ unsigned char buffer[BUFFER_LENGTH]; in_addr address; @@ -145,6 +135,9 @@ void CFCSNetwork::clock(unsigned int ms) if (length <= 0) return; + if (m_port == 0U) + return; + if (address.s_addr != m_address.s_addr || port != m_port) return; @@ -155,7 +148,7 @@ void CFCSNetwork::clock(unsigned int ms) writeInfo(); if (length == 130) - m_buffer.addData(buffer, 120U); + m_buffer.addData(buffer, 130U); } unsigned int CFCSNetwork::read(unsigned char* data) @@ -165,9 +158,14 @@ unsigned int CFCSNetwork::read(unsigned char* data) if (m_buffer.isEmpty()) return 0U; - ::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U); + unsigned char buffer[130U]; + m_buffer.getData(buffer, 130U); - m_buffer.getData(data + 35U, 120U); + ::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U); + ::memcpy(data + 35U, buffer, 120U); + + // Put the reflector name as the via callsign. + ::memcpy(data + 4U, buffer + 121U, 8U); data[34U] = m_n; m_n += 2U; @@ -192,3 +190,14 @@ void CFCSNetwork::writeInfo() m_socket.write(m_info, 100U, m_address, m_port); } + +void CFCSNetwork::writePing() +{ + if (m_port == 0U) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", m_ping, 25U); + + m_socket.write(m_ping, 25U, m_address, m_port); +} diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index bf6d610..a5ce229 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -36,11 +36,11 @@ public: void clearDestination(); - bool write(const unsigned char* data); + void write(const unsigned char* data); - bool writeLink(const std::string& reflector); + void writeLink(const std::string& reflector); - bool writeUnlink(); + void writeUnlink(unsigned int count = 1U); unsigned int read(unsigned char* data); @@ -53,14 +53,15 @@ private: bool m_debug; in_addr m_address; unsigned int m_port; + unsigned char* m_ping; unsigned char* m_info; - std::string m_callsign; std::string m_reflector; CRingBuffer m_buffer; std::map m_addresses; unsigned char m_n; void writeInfo(); + void writePing(); }; #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 6db2dc2..c4a80a6 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -46,6 +46,7 @@ const char* DEFAULT_INI_FILE = "/etc/YSFGateway.ini"; #include #include #include +#include int main(int argc, char** argv) { @@ -86,8 +87,7 @@ m_fcsNetwork(NULL), m_linkType(LINK_NONE), m_exclude(false), m_inactivityTimer(1000U), -m_lostTimer(1000U, 120U), -m_ysfPollTimer(1000U, 5U) +m_lostTimer(1000U, 120U) { } @@ -200,7 +200,7 @@ int CYSFGateway::run() unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); - std::string locator = m_conf.getLocator(); + std::string locator = calculateLocator(); unsigned int id = m_conf.getId(); unsigned int fcsPort = m_conf.getFCSNetworkPort(); @@ -250,15 +250,12 @@ int CYSFGateway::run() LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(3U); if (!revert) m_inactivityTimer.start(); m_lostTimer.start(); - m_ysfPollTimer.start(); m_linkType = LINK_YSF; } @@ -358,30 +355,22 @@ int CYSFGateway::run() if (m_wiresX != NULL) m_wiresX->processConnect(reflector); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(3U); m_lostTimer.start(); - m_ysfPollTimer.start(); } else { LogMessage("Disconnecting due to inactivity"); if (m_wiresX != NULL) m_wiresX->processDisconnect(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); m_lostTimer.stop(); - m_ysfPollTimer.stop(); m_linkType = LINK_NONE; } @@ -405,17 +394,10 @@ int CYSFGateway::run() m_inactivityTimer.stop(); m_lostTimer.stop(); - m_ysfPollTimer.stop(); m_linkType = LINK_NONE; } - m_ysfPollTimer.clock(ms); - if (m_ysfPollTimer.isRunning() && m_ysfPollTimer.hasExpired()) { - m_ysfNetwork->writePoll(); - m_ysfPollTimer.start(); - } - if (ms < 5U) CThread::sleep(5U); } @@ -472,15 +454,11 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); switch (status) { case WXS_CONNECT_YSF: { - if (m_linkType == LINK_YSF) { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - } + if (m_linkType == LINK_YSF) + m_ysfNetwork->writeUnlink(3U); + if (m_linkType == LINK_FCS) { - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); } @@ -488,13 +466,10 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(3U); m_inactivityTimer.start(); m_lostTimer.start(); - m_ysfPollTimer.start(); m_linkType = LINK_YSF; } @@ -503,23 +478,18 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u if (m_linkType == LINK_YSF) { LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_ysfPollTimer.stop(); m_linkType = LINK_NONE; } if (m_linkType == LINK_FCS) { LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); m_inactivityTimer.stop(); @@ -554,28 +524,21 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) if (m_wiresX != NULL) m_wiresX->processConnect(reflector); - if (m_linkType == LINK_YSF) { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - } + if (m_linkType == LINK_YSF) + m_ysfNetwork->writeUnlink(3U); + if (m_linkType == LINK_FCS) { - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); } LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); - m_ysfNetwork->writePoll(); + m_ysfNetwork->writePoll(3U); m_inactivityTimer.start(); m_lostTimer.start(); - m_ysfPollTimer.start(); m_linkType = LINK_YSF; } @@ -589,22 +552,14 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) id = "FCS00" + id.at(0U) + id.at(1U) + id.at(2U); if (m_linkType == LINK_YSF) { - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); - m_ysfPollTimer.stop(); - } - if (m_linkType == LINK_FCS) { - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); } + if (m_linkType == LINK_FCS) + m_fcsNetwork->writeUnlink(3U); LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U); - m_fcsNetwork->writeLink(id); - m_fcsNetwork->writeLink(id); m_fcsNetwork->writeLink(id); m_inactivityTimer.start(); @@ -620,23 +575,18 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); - m_ysfNetwork->writeUnlink(); + m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_ysfPollTimer.stop(); m_linkType = LINK_NONE; } if (m_linkType == LINK_FCS) { LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); - m_fcsNetwork->writeUnlink(); + m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); m_inactivityTimer.stop(); @@ -649,3 +599,53 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) break; } } + +std::string CYSFGateway::calculateLocator() +{ + std::string locator; + + float latitude = m_conf.getLatitude(); + float longitude = m_conf.getLongitude(); + + if (latitude < -90.0F || latitude > 90.0F) + return "AA00AA"; + + if (longitude < -360.0F || longitude > 360.0F) + return "AA00AA"; + + latitude += 90.0F; + + if (longitude > 180.0F) + longitude -= 360.0F; + + if (longitude < -180.0F) + longitude += 360.0F; + + longitude += 180.0F; + + float lon = ::floor(longitude / 20.0F); + float lat = ::floor(latitude / 10.0F); + + locator += 'A' + (unsigned int)lon; + locator += 'A' + (unsigned int)lat; + + longitude -= lon * 20.0F; + latitude -= lat * 10.0F; + + lon = ::floor(longitude / 2.0F); + lat = ::floor(latitude / 1.0F); + + locator += '0' + (unsigned int)lon; + locator += '0' + (unsigned int)lat; + + longitude -= lon * 2.0F; + latitude -= lat * 1.0F; + + lon = ::floor(longitude / (2.0F / 24.0F)); + lat = ::floor(latitude / (1.0F / 24.0F)); + + locator += 'A' + (unsigned int)lon; + locator += 'A' + (unsigned int)lat; + + return locator; +} diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 1aebf76..6396073 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -56,8 +56,8 @@ private: bool m_exclude; CTimer m_inactivityTimer; CTimer m_lostTimer; - CTimer m_ysfPollTimer; + std::string calculateLocator(); void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); void processDTMF(const unsigned char* buffer, unsigned char dt); void createGPS(); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 85d6d42..37c4ab0 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -15,7 +15,6 @@ TXFrequency=439475000 Power=1 Latitude=0.0 Longitude=0.0 -Locator=IO90TT Height=0 Name=Nowhere Description=Multi-Mode Repeater diff --git a/YSFGateway/YSFNetwork.cpp b/YSFGateway/YSFNetwork.cpp index 93e84f0..8a99c1d 100644 --- a/YSFGateway/YSFNetwork.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -34,7 +34,8 @@ m_address(), m_port(0U), m_poll(NULL), m_unlink(NULL), -m_buffer(1000U, "YSF Network Buffer") +m_buffer(1000U, "YSF Network Buffer"), +m_pollTimer(1000U, 5U) { m_poll = new unsigned char[14U]; ::memcpy(m_poll + 0U, "YSFP", 4U); @@ -58,7 +59,8 @@ m_address(), m_port(0U), m_poll(NULL), m_unlink(NULL), -m_buffer(1000U, "YSF Network Buffer") +m_buffer(1000U, "YSF Network Buffer"), +m_pollTimer(1000U, 5U) { m_poll = new unsigned char[14U]; ::memcpy(m_poll + 0U, "YSFP", 4U); @@ -97,42 +99,47 @@ void CYSFNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; m_port = 0U; + + m_pollTimer.stop(); } -bool CYSFNetwork::write(const unsigned char* data) +void CYSFNetwork::write(const unsigned char* data) { assert(data != NULL); if (m_port == 0U) - return true; + return; if (m_debug) CUtils::dump(1U, "YSF Network Data Sent", data, 155U); - return m_socket.write(data, 155U, m_address, m_port); + m_socket.write(data, 155U, m_address, m_port); } -bool CYSFNetwork::writePoll() -{ - if (m_port == 0U) - return true; - - return m_socket.write(m_poll, 14U, m_address, m_port); -} - -bool CYSFNetwork::writeUnlink() -{ - if (m_port == 0U) - return true; - - return m_socket.write(m_unlink, 14U, m_address, m_port); -} - -void CYSFNetwork::clock(unsigned int ms) +void CYSFNetwork::writePoll(unsigned int count) { if (m_port == 0U) return; + m_pollTimer.start(); + + for (unsigned int i = 0U; i < count; i++) + m_socket.write(m_poll, 14U, m_address, m_port); +} + +void CYSFNetwork::writeUnlink(unsigned int count) +{ + m_pollTimer.stop(); + + if (m_port == 0U) + return; + + for (unsigned int i = 0U; i < count; i++) + m_socket.write(m_unlink, 14U, m_address, m_port); +} + +void CYSFNetwork::clock(unsigned int ms) +{ unsigned char buffer[BUFFER_LENGTH]; in_addr address; @@ -141,6 +148,13 @@ void CYSFNetwork::clock(unsigned int ms) if (length <= 0) return; + if (m_port == 0U) + return; + + m_pollTimer.clock(ms); + if (m_pollTimer.isRunning() && m_pollTimer.hasExpired()) + writePoll(); + if (address.s_addr != m_address.s_addr || port != m_port) return; diff --git a/YSFGateway/YSFNetwork.h b/YSFGateway/YSFNetwork.h index bd8e746..eeb9708 100644 --- a/YSFGateway/YSFNetwork.h +++ b/YSFGateway/YSFNetwork.h @@ -22,6 +22,7 @@ #include "YSFDefines.h" #include "UDPSocket.h" #include "RingBuffer.h" +#include "Timer.h" #include #include @@ -37,10 +38,10 @@ public: void setDestination(const in_addr& address, unsigned int port); void clearDestination(); - bool write(const unsigned char* data); + void write(const unsigned char* data); - bool writePoll(); - bool writeUnlink(); + void writePoll(unsigned int count = 1U); + void writeUnlink(unsigned int count = 1U); unsigned int read(unsigned char* data); @@ -56,6 +57,7 @@ private: unsigned char* m_poll; unsigned char* m_unlink; CRingBuffer m_buffer; + CTimer m_pollTimer; }; #endif From 22e5bb523fdddaa31f2cc69b56e08c9e5b33cb42 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 19:44:23 +0000 Subject: [PATCH 08/20] More changes, including FCS linking at startup. --- YSFGateway/Conf.cpp | 78 +++++++-------- YSFGateway/Conf.h | 21 ++-- YSFGateway/YSFGateway.cpp | 202 ++++++++++++++++++++++---------------- YSFGateway/YSFGateway.h | 1 + YSFGateway/YSFGateway.ini | 13 +-- 5 files changed, 174 insertions(+), 141 deletions(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 90ee901..0e7aa6b 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -32,6 +32,7 @@ enum SECTION { SECTION_INFO, SECTION_LOG, SECTION_APRS_FI, + SECTION_NETWORK, SECTION_YSF_NETWORK, SECTION_FCS_NETWORK }; @@ -63,6 +64,10 @@ m_aprsServer(), m_aprsPort(0U), m_aprsPassword(), m_aprsDescription(), +m_networkStartup(), +m_networkInactivityTimeout(0U), +m_networkRevert(false), +m_networkDebug(false), m_ysfNetworkEnabled(false), m_ysfNetworkPort(0U), m_ysfNetworkHosts(), @@ -71,13 +76,8 @@ m_ysfNetworkParrotAddress("127.0.0.1"), m_ysfNetworkParrotPort(0U), m_ysfNetworkYSF2DMRAddress("127.0.0.1"), m_ysfNetworkYSF2DMRPort(0U), -m_ysfNetworkStartup(), -m_ysfNetworkInactivityTimeout(0U), -m_ysfNetworkRevert(false), -m_ysfNetworkDebug(false), m_fcsNetworkEnabled(false), -m_fcsNetworkPort(0U), -m_fcsNetworkDebug(false) +m_fcsNetworkPort(0U) { } @@ -109,6 +109,8 @@ bool CConf::read() section = SECTION_LOG; else if (::strncmp(buffer, "[aprs.fi]", 9U) == 0) section = SECTION_APRS_FI; + else if (::strncmp(buffer, "[Network]", 9U) == 0) + section = SECTION_NETWORK; else if (::strncmp(buffer, "[YSF Network]", 13U) == 0) section = SECTION_YSF_NETWORK; else if (::strncmp(buffer, "[FCS Network]", 13U) == 0) @@ -184,6 +186,15 @@ bool CConf::read() m_aprsPassword = value; else if (::strcmp(key, "Description") == 0) m_aprsDescription = value; + } else if (section == SECTION_NETWORK) { + if (::strcmp(key, "Startup") == 0) + m_networkStartup = value; + else if (::strcmp(key, "InactivityTimeout") == 0) + m_networkInactivityTimeout = (unsigned int)::atoi(value); + else if (::strcmp(key, "Revert") == 0) + m_networkRevert = ::atoi(value) == 1; + else if (::strcmp(key, "Debug") == 0) + m_networkDebug = ::atoi(value) == 1; } else if (section == SECTION_YSF_NETWORK) { if (::strcmp(key, "Enable") == 0) m_ysfNetworkEnabled = ::atoi(value) == 1; @@ -201,21 +212,11 @@ bool CConf::read() m_ysfNetworkYSF2DMRAddress = value; else if (::strcmp(key, "YSF2DMRPort") == 0) m_ysfNetworkYSF2DMRPort = (unsigned int)::atoi(value); - else if (::strcmp(key, "Startup") == 0) - m_ysfNetworkStartup = value; - else if (::strcmp(key, "InactivityTimeout") == 0) - m_ysfNetworkInactivityTimeout = (unsigned int)::atoi(value); - else if (::strcmp(key, "Revert") == 0) - m_ysfNetworkRevert = ::atoi(value) == 1; - else if (::strcmp(key, "Debug") == 0) - m_ysfNetworkDebug = ::atoi(value) == 1; } else if (section == SECTION_FCS_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fcsNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Port") == 0) m_fcsNetworkPort = (unsigned int)::atoi(value); - else if (::strcmp(key, "Debug") == 0) - m_fcsNetworkDebug = ::atoi(value) == 1; } } @@ -349,6 +350,26 @@ std::string CConf::getAPRSDescription() const return m_aprsDescription; } +std::string CConf::getNetworkStartup() const +{ + return m_networkStartup; +} + +unsigned int CConf::getNetworkInactivityTimeout() const +{ + return m_networkInactivityTimeout; +} + +bool CConf::getNetworkRevert() const +{ + return m_networkRevert; +} + +bool CConf::getNetworkDebug() const +{ + return m_networkDebug; +} + bool CConf::getYSFNetworkEnabled() const { return m_ysfNetworkEnabled; @@ -389,26 +410,6 @@ unsigned int CConf::getYSFNetworkYSF2DMRPort() const return m_ysfNetworkYSF2DMRPort; } -std::string CConf::getYSFNetworkStartup() const -{ - return m_ysfNetworkStartup; -} - -unsigned int CConf::getYSFNetworkInactivityTimeout() const -{ - return m_ysfNetworkInactivityTimeout; -} - -bool CConf::getYSFNetworkRevert() const -{ - return m_ysfNetworkRevert; -} - -bool CConf::getYSFNetworkDebug() const -{ - return m_ysfNetworkDebug; -} - bool CConf::getFCSNetworkEnabled() const { return m_fcsNetworkEnabled; @@ -418,8 +419,3 @@ unsigned int CConf::getFCSNetworkPort() const { return m_fcsNetworkPort; } - -bool CConf::getFCSNetworkDebug() const -{ - return m_fcsNetworkDebug; -} diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 01e20af..092a6d5 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -63,6 +63,12 @@ public: std::string getAPRSPassword() const; std::string getAPRSDescription() const; + // The Network section + std::string getNetworkStartup() const; + unsigned int getNetworkInactivityTimeout() const; + bool getNetworkRevert() const; + bool getNetworkDebug() const; + // The YSF Network section bool getYSFNetworkEnabled() const; unsigned int getYSFNetworkPort() const; @@ -72,15 +78,10 @@ public: unsigned int getYSFNetworkParrotPort() const; std::string getYSFNetworkYSF2DMRAddress() const; unsigned int getYSFNetworkYSF2DMRPort() const; - std::string getYSFNetworkStartup() const; - unsigned int getYSFNetworkInactivityTimeout() const; - bool getYSFNetworkRevert() const; - bool getYSFNetworkDebug() const; // The FCS Network section bool getFCSNetworkEnabled() const; unsigned int getFCSNetworkPort() const; - bool getFCSNetworkDebug() const; private: std::string m_file; @@ -113,6 +114,11 @@ private: std::string m_aprsPassword; std::string m_aprsDescription; + std::string m_networkStartup; + unsigned int m_networkInactivityTimeout; + bool m_networkRevert; + bool m_networkDebug; + bool m_ysfNetworkEnabled; unsigned int m_ysfNetworkPort; std::string m_ysfNetworkHosts; @@ -121,14 +127,9 @@ private: unsigned int m_ysfNetworkParrotPort; std::string m_ysfNetworkYSF2DMRAddress; unsigned int m_ysfNetworkYSF2DMRPort; - std::string m_ysfNetworkStartup; - unsigned int m_ysfNetworkInactivityTimeout; - bool m_ysfNetworkRevert; - bool m_ysfNetworkDebug; bool m_fcsNetworkEnabled; unsigned int m_fcsNetworkPort; - bool m_fcsNetworkDebug; }; #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index c4a80a6..b1351f3 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -119,7 +119,8 @@ int CYSFGateway::run() if (pid == -1) { ::LogWarning("Couldn't fork() , exiting"); return -1; - } else if (pid != 0) + } + else if (pid != 0) exit(EXIT_SUCCESS); // Create new session and process group @@ -170,13 +171,13 @@ int CYSFGateway::run() #endif m_callsign = m_conf.getCallsign(); - m_suffix = m_conf.getSuffix(); + m_suffix = m_conf.getSuffix(); - bool debug = m_conf.getYSFNetworkDebug(); - in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); - unsigned int rptPort = m_conf.getRptPort(); + bool debug = m_conf.getNetworkDebug(); + in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); + unsigned int rptPort = m_conf.getRptPort(); std::string myAddress = m_conf.getMyAddress(); - unsigned int myPort = m_conf.getMyPort(); + unsigned int myPort = m_conf.getMyPort(); CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); rptNetwork.setDestination(rptAddress, rptPort); @@ -188,63 +189,55 @@ int CYSFGateway::run() return 1; } - unsigned int ysfPort = m_conf.getYSFNetworkPort(); - - m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); - ret = m_ysfNetwork->open(); - if (!ret) { - ::LogError("Cannot open the YSF reflector network port"); - ::LogFinalise(); - return 1; - } - - unsigned int txFrequency = m_conf.getTxFrequency(); - unsigned int rxFrequency = m_conf.getRxFrequency(); - std::string locator = calculateLocator(); - unsigned int id = m_conf.getId(); - - unsigned int fcsPort = m_conf.getFCSNetworkPort(); - - m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug); - ret = m_fcsNetwork->open(); - if (!ret) { - ::LogError("Cannot open the FCS reflector network port"); - ::LogFinalise(); - return 1; - } - - m_inactivityTimer.setTimeout(m_conf.getYSFNetworkInactivityTimeout() * 60U); - - bool revert = m_conf.getYSFNetworkRevert(); - std::string startup = m_conf.getYSFNetworkStartup(); - - bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); if (ysfNetworkEnabled) { - std::string fileName = m_conf.getYSFNetworkHosts(); - unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); + unsigned int ysfPort = m_conf.getYSFNetworkPort(); - m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime); + m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); + ret = m_ysfNetwork->open(); + if (!ret) { + ::LogError("Cannot open the YSF reflector network port"); + ::LogFinalise(); + return 1; + } + } - std::string name = m_conf.getName(); + bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); + if (fcsNetworkEnabled) { + unsigned int txFrequency = m_conf.getTxFrequency(); + unsigned int rxFrequency = m_conf.getRxFrequency(); + std::string locator = calculateLocator(); + unsigned int id = m_conf.getId(); - m_wiresX->setInfo(name, txFrequency, rxFrequency); + unsigned int fcsPort = m_conf.getFCSNetworkPort(); - std::string address = m_conf.getYSFNetworkParrotAddress(); - unsigned int port = m_conf.getYSFNetworkParrotPort(); + m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug); + ret = m_fcsNetwork->open(); + if (!ret) { + ::LogError("Cannot open the FCS reflector network port"); + ::LogFinalise(); + return 1; + } + } - if (port > 0U) - m_wiresX->setParrot(address, port); + m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U); - address = m_conf.getYSFNetworkYSF2DMRAddress(); - port = m_conf.getYSFNetworkYSF2DMRPort(); + bool revert = m_conf.getNetworkRevert(); + std::string startup = m_conf.getNetworkStartup(); - if (port > 0U) - m_wiresX->setYSF2DMR(address, port); + if (!startup.empty()) { + if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { + LogMessage("Automatic connection to %s", startup.c_str()); - m_wiresX->start(); + m_fcsNetwork->writeLink(startup); - if (!startup.empty()) { + if (!revert) + m_inactivityTimer.start(); + + m_lostTimer.start(); + + m_linkType = LINK_FCS; + } else if (m_ysfNetwork != NULL) { CYSFReflector* reflector = m_wiresX->getReflector(startup); if (reflector != NULL) { LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); @@ -267,6 +260,8 @@ int CYSFGateway::run() LogMessage("Starting YSFGateway-%s", VERSION); + createWiresX(&rptNetwork); + createGPS(); for (;;) { @@ -284,8 +279,7 @@ int CYSFGateway::run() // Don't send out control data m_exclude = (dt == YSF_DT_DATA_FR_MODE); - if (m_wiresX != NULL) - processWiresX(buffer, fi, dt, fn, ft); + processWiresX(buffer, fi, dt, fn, ft); processDTMF(buffer, dt); @@ -293,13 +287,13 @@ int CYSFGateway::run() m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); } - if (ysfNetworkEnabled && m_linkType == LINK_YSF && !m_exclude) { + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) { m_ysfNetwork->write(buffer); if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) m_inactivityTimer.start(); } - if (fcsNetworkEnabled && m_linkType == LINK_FCS && !m_exclude) { + if (m_fcsNetwork != NULL && m_linkType == LINK_FCS && !m_exclude) { if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) { m_fcsNetwork->write(buffer); m_inactivityTimer.start(); @@ -314,20 +308,27 @@ int CYSFGateway::run() } } - while (m_ysfNetwork->read(buffer) > 0U) { - if (ysfNetworkEnabled && m_linkType == LINK_YSF) { - // Only pass through YSF data packets - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) - rptNetwork.write(buffer); + if (m_ysfNetwork != NULL) { + while (m_ysfNetwork->read(buffer) > 0U) { + if (m_linkType == LINK_YSF) { + // Only pass through YSF data packets + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + rptNetwork.write(buffer); - m_lostTimer.start(); + m_lostTimer.start(); + } } } - while (m_fcsNetwork->read(buffer) > 0U) { - if (fcsNetworkEnabled && m_linkType == LINK_FCS) { - rptNetwork.write(buffer); - m_lostTimer.start(); + if (m_fcsNetwork != NULL) { + while (m_fcsNetwork->read(buffer) > 0U) { + if (m_linkType == LINK_FCS) { + // Only pass through YSF data packets + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + rptNetwork.write(buffer); + + m_lostTimer.start(); + } } } @@ -335,25 +336,25 @@ int CYSFGateway::run() stopWatch.start(); rptNetwork.clock(ms); - m_ysfNetwork->clock(ms); - m_fcsNetwork->clock(ms); + if (m_ysfNetwork != NULL) + m_ysfNetwork->clock(ms); + if (m_fcsNetwork != NULL) + m_fcsNetwork->clock(ms); if (m_gps != NULL) m_gps->clock(ms); - if (m_wiresX != NULL) - m_wiresX->clock(ms); + m_wiresX->clock(ms); m_inactivityTimer.clock(ms); if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { if (m_linkType == LINK_YSF) { CYSFReflector* reflector = NULL; - if (revert && !startup.empty() && m_wiresX != NULL) + if (revert && !startup.empty()) reflector = m_wiresX->getReflector(startup); if (reflector != NULL) { LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - if (m_wiresX != NULL) - m_wiresX->processConnect(reflector); + m_wiresX->processConnect(reflector); m_ysfNetwork->writeUnlink(3U); @@ -364,8 +365,7 @@ int CYSFGateway::run() } else { LogMessage("Disconnecting due to inactivity"); - if (m_wiresX != NULL) - m_wiresX->processDisconnect(); + m_wiresX->processDisconnect(); m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); @@ -383,7 +383,7 @@ int CYSFGateway::run() if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) { LogWarning("Link has failed, polls lost"); - if (m_wiresX != NULL) + if (m_linkType == LINK_YSF) m_wiresX->processDisconnect(); if (m_fcsNetwork != NULL) @@ -403,16 +403,22 @@ int CYSFGateway::run() } rptNetwork.close(); - m_ysfNetwork->close(); - m_fcsNetwork->close(); if (m_gps != NULL) { m_gps->close(); delete m_gps; } - delete m_ysfNetwork; - delete m_fcsNetwork; + if (m_ysfNetwork != NULL) { + m_ysfNetwork->close(); + delete m_ysfNetwork; + } + + if (m_fcsNetwork != NULL) { + m_fcsNetwork->close(); + delete m_fcsNetwork; + } + delete m_wiresX; ::LogFinalise(); @@ -447,6 +453,36 @@ void CYSFGateway::createGPS() } } +void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork) +{ + assert(rptNetwork != NULL); + + std::string fileName = m_conf.getYSFNetworkHosts(); + unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); + + m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, fileName, reloadTime); + + std::string name = m_conf.getName(); + + unsigned int txFrequency = m_conf.getTxFrequency(); + unsigned int rxFrequency = m_conf.getRxFrequency(); + m_wiresX->setInfo(name, txFrequency, rxFrequency); + + std::string address = m_conf.getYSFNetworkParrotAddress(); + unsigned int port = m_conf.getYSFNetworkParrotPort(); + + if (port > 0U) + m_wiresX->setParrot(address, port); + + address = m_conf.getYSFNetworkYSF2DMRAddress(); + port = m_conf.getYSFNetworkYSF2DMRPort(); + + if (port > 0U) + m_wiresX->setYSF2DMR(address, port); + + m_wiresX->start(); +} + void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft) { assert(buffer != NULL); @@ -521,8 +557,7 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) std::string id = m_dtmf.getReflector(); CYSFReflector* reflector = m_wiresX->getReflector(id); if (reflector != NULL) { - if (m_wiresX != NULL) - m_wiresX->processConnect(reflector); + m_wiresX->processConnect(reflector); if (m_linkType == LINK_YSF) m_ysfNetwork->writeUnlink(3U); @@ -570,8 +605,7 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) break; case WXS_DISCONNECT: if (m_linkType == LINK_YSF) { - if (m_wiresX != NULL) - m_wiresX->processDisconnect(); + m_wiresX->processDisconnect(); LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 6396073..1f553d0 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -60,6 +60,7 @@ private: std::string calculateLocator(); void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); void processDTMF(const unsigned char* buffer, unsigned char dt); + void createWiresX(CYSFNetwork* rptNetwork); void createGPS(); }; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 37c4ab0..3fd3432 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -34,6 +34,12 @@ Port=14580 Password=9999 Description=APRS Description +[Network] +# Startup= +InactivityTimeout=10 +# Revert=0 +Debug=0 + [YSF Network] Enable=1 Port=42000 @@ -43,12 +49,7 @@ ParrotAddress=127.0.0.1 ParrotPort=42012 YSF2DMRAddress=127.0.0.1 YSF2DMRPort=42013 -# Startup= -InactivityTimeout=10 -# Revert=0 -Debug=0 [FCS Network] Enable=1 -Port=42000 -Debug=0 +Port=42001 From 28a0a78d8445ef6bce81c85d7c5f8fbc071abffa Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 20:14:49 +0000 Subject: [PATCH 09/20] Almost complete, but it doesn't work! --- YSFGateway/FCSNetwork.cpp | 52 ++++++++++++++-- YSFGateway/FCSNetwork.h | 9 +++ YSFGateway/YSFGateway.cpp | 123 ++++++++++++++++++-------------------- YSFGateway/YSFGateway.h | 1 + YSFGateway/YSFGateway.ini | 2 +- 5 files changed, 117 insertions(+), 70 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 4923205..7746509 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -38,7 +38,9 @@ m_ping(NULL), m_info(NULL), m_reflector(), m_buffer(1000U, "FCS Network Buffer"), -m_n(0U) +m_n(0U), +m_pingTimer(1000U, 5U), +m_state(FCS_UNLINKED) { m_info = new unsigned char[100U]; ::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); @@ -71,6 +73,10 @@ void CFCSNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; m_port = 0U; + + m_pingTimer.stop(); + + m_state = FCS_UNLINKED; } void CFCSNetwork::write(const unsigned char* data) @@ -80,6 +86,9 @@ void CFCSNetwork::write(const unsigned char* data) if (m_port == 0U) return; + if (m_state != FCS_LINKED) + return; + unsigned char buffer[130U]; ::memset(buffer + 0U, ' ', 130U); ::memcpy(buffer + 0U, data + 35U, 120U); @@ -114,6 +123,10 @@ void CFCSNetwork::writeLink(const std::string& reflector) ::memcpy(m_ping + 10U, m_reflector.c_str(), 8U); writePing(); + + m_pingTimer.start(); + + m_state = FCS_LINKING; } void CFCSNetwork::writeUnlink(unsigned int count) @@ -123,6 +136,10 @@ void CFCSNetwork::writeUnlink(unsigned int count) for (unsigned int i = 0U; i < count; i++) m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port); + + m_pingTimer.stop(); + + m_state = FCS_UNLINKED; } void CFCSNetwork::clock(unsigned int ms) @@ -138,17 +155,33 @@ void CFCSNetwork::clock(unsigned int ms) if (m_port == 0U) return; + m_pingTimer.clock(ms); + if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { + writePing(); + m_pingTimer.start(); + } + if (address.s_addr != m_address.s_addr || port != m_port) return; if (m_debug) CUtils::dump(1U, "FCS Network Data Received", buffer, length); - if (length == 7 || length == 10) + if (length == 7) { + m_state = FCS_LINKED; writeInfo(); + } - if (length == 130) - m_buffer.addData(buffer, 130U); + if (length == 10 && m_state == FCS_LINKING) { + m_state = FCS_LINKED; + writeInfo(); + } + + if (length == 10 || length == 130) { + unsigned char len = length; + m_buffer.addData(&len, 1U); + m_buffer.addData(buffer, len); + } } unsigned int CFCSNetwork::read(unsigned char* data) @@ -158,8 +191,17 @@ unsigned int CFCSNetwork::read(unsigned char* data) if (m_buffer.isEmpty()) return 0U; + unsigned char len = 0U; + m_buffer.getData(&len, 1U); + + // Pass pings up to the gateway to reset the lost timer. + if (len == 10U) { + m_buffer.getData(data, len); + return 10U; + } + unsigned char buffer[130U]; - m_buffer.getData(buffer, 130U); + m_buffer.getData(buffer, len); ::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U); ::memcpy(data + 35U, buffer, 120U); diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index a5ce229..de6b1c1 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -22,11 +22,18 @@ #include "YSFDefines.h" #include "UDPSocket.h" #include "RingBuffer.h" +#include "Timer.h" #include #include #include +enum FCS_STATE { + FCS_UNLINKED, + FCS_LINKING, + FCS_LINKED +}; + class CFCSNetwork { public: CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug); @@ -59,6 +66,8 @@ private: CRingBuffer m_buffer; std::map m_addresses; unsigned char m_n; + CTimer m_pingTimer; + FCS_STATE m_state; void writeInfo(); void writePing(); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index b1351f3..d1444d1 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -223,37 +223,8 @@ int CYSFGateway::run() m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U); bool revert = m_conf.getNetworkRevert(); - std::string startup = m_conf.getNetworkStartup(); - if (!startup.empty()) { - if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { - LogMessage("Automatic connection to %s", startup.c_str()); - - m_fcsNetwork->writeLink(startup); - - if (!revert) - m_inactivityTimer.start(); - - m_lostTimer.start(); - - m_linkType = LINK_FCS; - } else if (m_ysfNetwork != NULL) { - CYSFReflector* reflector = m_wiresX->getReflector(startup); - if (reflector != NULL) { - LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(3U); - - if (!revert) - m_inactivityTimer.start(); - - m_lostTimer.start(); - - m_linkType = LINK_YSF; - } - } - } + startupLinking(); CStopWatch stopWatch; stopWatch.start(); @@ -347,50 +318,38 @@ int CYSFGateway::run() m_inactivityTimer.clock(ms); if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { if (m_linkType == LINK_YSF) { - CYSFReflector* reflector = NULL; - if (revert && !startup.empty()) - reflector = m_wiresX->getReflector(startup); + LogMessage("Disconnecting due to inactivity"); + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } - if (reflector != NULL) { - LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - - m_wiresX->processConnect(reflector); - - m_ysfNetwork->writeUnlink(3U); - - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); - m_ysfNetwork->writePoll(3U); - - m_lostTimer.start(); - } else { - LogMessage("Disconnecting due to inactivity"); - - m_wiresX->processDisconnect(); - - m_ysfNetwork->writeUnlink(3U); - m_ysfNetwork->clearDestination(); - - m_lostTimer.stop(); - - m_linkType = LINK_NONE; - } + if (m_linkType == LINK_FCS) { + LogMessage("Disconnecting due to inactivity"); + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); } m_inactivityTimer.stop(); + m_lostTimer.stop(); + + m_linkType = LINK_NONE; + + startupLinking(); } m_lostTimer.clock(ms); if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) { - LogWarning("Link has failed, polls lost"); - - if (m_linkType == LINK_YSF) + if (m_linkType == LINK_YSF) { + LogWarning("Link has failed, polls lost"); m_wiresX->processDisconnect(); - - if (m_fcsNetwork != NULL) - m_fcsNetwork->clearDestination(); - - if (m_ysfNetwork != NULL) m_ysfNetwork->clearDestination(); + } + + if (m_fcsNetwork != NULL) { + LogWarning("Link has failed, polls lost"); + m_fcsNetwork->clearDestination(); + } m_inactivityTimer.stop(); m_lostTimer.stop(); @@ -683,3 +642,39 @@ std::string CYSFGateway::calculateLocator() return locator; } + +void CYSFGateway::startupLinking() +{ + std::string startup = m_conf.getNetworkStartup(); + bool revert = m_conf.getNetworkRevert(); + + if (!startup.empty()) { + if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { + LogMessage("Automatic (re-)connection to %s", startup.c_str()); + + m_fcsNetwork->writeLink(startup); + + if (!revert) + m_inactivityTimer.start(); + + m_lostTimer.start(); + + m_linkType = LINK_FCS; + } else if (m_ysfNetwork != NULL) { + CYSFReflector* reflector = m_wiresX->getReflector(startup); + if (reflector != NULL) { + LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); + + m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(3U); + + if (!revert) + m_inactivityTimer.start(); + + m_lostTimer.start(); + + m_linkType = LINK_YSF; + } + } + } +} diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 1f553d0..5e71b75 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -57,6 +57,7 @@ private: CTimer m_inactivityTimer; CTimer m_lostTimer; + void startupLinking(); std::string calculateLocator(); void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); void processDTMF(const unsigned char* buffer, unsigned char dt); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 3fd3432..16b41af 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -35,7 +35,7 @@ Password=9999 Description=APRS Description [Network] -# Startup= +# Startup=FCS00120 InactivityTimeout=10 # Revert=0 Debug=0 From b56ef7051f242e63d94afe0ff56de5113bd2d474 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 22 Feb 2018 22:06:24 +0000 Subject: [PATCH 10/20] Handle unknown FCS reflector better. --- YSFGateway/FCSNetwork.cpp | 8 +++++--- YSFGateway/FCSNetwork.h | 2 +- YSFGateway/YSFGateway.cpp | 37 ++++++++++++++++++++++++------------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 7746509..cf6f4e4 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -100,19 +100,19 @@ void CFCSNetwork::write(const unsigned char* data) m_socket.write(buffer, 130U, m_address, m_port); } -void CFCSNetwork::writeLink(const std::string& reflector) +bool CFCSNetwork::writeLink(const std::string& reflector) { if (m_port == 0U) { std::string name = reflector.substr(0U, 6U); if (m_addresses.count(name) == 0U) { LogError("Unknown FCS reflector - %s", name.c_str()); - return; + return false; } m_address = m_addresses[name]; if (m_address.s_addr == INADDR_NONE) { LogError("FCS reflector %s has no address", name.c_str()); - return; + return false; } } @@ -127,6 +127,8 @@ void CFCSNetwork::writeLink(const std::string& reflector) m_pingTimer.start(); m_state = FCS_LINKING; + + return true; } void CFCSNetwork::writeUnlink(unsigned int count) diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index de6b1c1..c2a6f21 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -45,7 +45,7 @@ public: void write(const unsigned char* data); - void writeLink(const std::string& reflector); + bool writeLink(const std::string& reflector); void writeUnlink(unsigned int count = 1U); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index d1444d1..ce20871 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -552,14 +552,20 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) if (m_linkType == LINK_FCS) m_fcsNetwork->writeUnlink(3U); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U); - m_fcsNetwork->writeLink(id); - - m_inactivityTimer.start(); - m_lostTimer.start(); - - m_linkType = LINK_FCS; + bool ok = m_fcsNetwork->writeLink(id); + if (ok) { + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_FCS; + } else { + LogMessage("Unknown reflector - %s", id.c_str()); + } } break; case WXS_DISCONNECT: @@ -652,14 +658,19 @@ void CYSFGateway::startupLinking() if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { LogMessage("Automatic (re-)connection to %s", startup.c_str()); - m_fcsNetwork->writeLink(startup); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; - if (!revert) - m_inactivityTimer.start(); - - m_lostTimer.start(); - - m_linkType = LINK_FCS; + bool ok = m_fcsNetwork->writeLink(startup); + if (ok) { + if (!revert) + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_FCS; + } else { + LogMessage("Unknown reflector - %s", startup.c_str()); + } } else if (m_ysfNetwork != NULL) { CYSFReflector* reflector = m_wiresX->getReflector(startup); if (reflector != NULL) { From 750e13222e12550a2244ed72631e6f6931392b06 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 23 Feb 2018 07:19:58 +0000 Subject: [PATCH 11/20] Modify the revert handling. --- YSFGateway/FCSNetwork.cpp | 6 +- YSFGateway/YSFGateway.cpp | 120 +++++++++++++++++++++++--------------- YSFGateway/YSFGateway.h | 2 + YSFGateway/YSFGateway.ini | 2 +- 4 files changed, 81 insertions(+), 49 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index cf6f4e4..a2529ce 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -25,7 +25,7 @@ #include #include -const char* FCS_VERSION = "MMDVM v.01"; +const char* FCS_VERSION = "MMDVM"; const unsigned int BUFFER_LENGTH = 200U; @@ -44,9 +44,11 @@ m_state(FCS_UNLINKED) { m_info = new unsigned char[100U]; ::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); + ::memset(m_info + 43U, ' ', 57U); m_ping = new unsigned char[25U]; - ::sprintf((char*)m_ping, "PING%6.6s ", callsign.c_str()); + ::sprintf((char*)m_ping, "PING%6.6s", callsign.c_str()); + ::memset(m_ping + 10U, ' ', 15U); } CFCSNetwork::~CFCSNetwork() diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index ce20871..61cabb4 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -85,6 +85,8 @@ m_dtmf(), m_ysfNetwork(NULL), m_fcsNetwork(NULL), m_linkType(LINK_NONE), +m_current(), +m_startup(), m_exclude(false), m_inactivityTimer(1000U), m_lostTimer(1000U, 120U) @@ -171,13 +173,13 @@ int CYSFGateway::run() #endif m_callsign = m_conf.getCallsign(); - m_suffix = m_conf.getSuffix(); + m_suffix = m_conf.getSuffix(); - bool debug = m_conf.getNetworkDebug(); - in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); - unsigned int rptPort = m_conf.getRptPort(); + bool debug = m_conf.getNetworkDebug(); + in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); + unsigned int rptPort = m_conf.getRptPort(); std::string myAddress = m_conf.getMyAddress(); - unsigned int myPort = m_conf.getMyPort(); + unsigned int myPort = m_conf.getMyPort(); CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); rptNetwork.setDestination(rptAddress, rptPort); @@ -222,6 +224,7 @@ int CYSFGateway::run() m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U); + m_startup = m_conf.getNetworkStartup(); bool revert = m_conf.getNetworkRevert(); startupLinking(); @@ -317,25 +320,47 @@ int CYSFGateway::run() m_inactivityTimer.clock(ms); if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { - if (m_linkType == LINK_YSF) { - LogMessage("Disconnecting due to inactivity"); - m_wiresX->processDisconnect(); - m_ysfNetwork->writeUnlink(3U); - m_ysfNetwork->clearDestination(); + if (revert) { + if (m_current != m_startup) { + if (m_linkType == LINK_YSF) { + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } + + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + } + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + + startupLinking(); + } else { + m_inactivityTimer.start(); + } + } else { + if (m_linkType == LINK_YSF) { + LogMessage("Disconnecting due to inactivity"); + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } + + if (m_linkType == LINK_FCS) { + LogMessage("Disconnecting due to inactivity"); + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + } + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; } - - if (m_linkType == LINK_FCS) { - LogMessage("Disconnecting due to inactivity"); - m_fcsNetwork->writeUnlink(3U); - m_fcsNetwork->clearDestination(); - } - - m_inactivityTimer.stop(); - m_lostTimer.stop(); - - m_linkType = LINK_NONE; - - startupLinking(); } m_lostTimer.clock(ms); @@ -351,9 +376,9 @@ int CYSFGateway::run() m_fcsNetwork->clearDestination(); } + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_NONE; } @@ -463,9 +488,9 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); + m_current = reflector->m_id; m_inactivityTimer.start(); m_lostTimer.start(); - m_linkType = LINK_YSF; } break; @@ -476,9 +501,9 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_NONE; } if (m_linkType == LINK_FCS) { @@ -487,9 +512,9 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_NONE; } break; @@ -531,9 +556,9 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); + m_current = id; m_inactivityTimer.start(); m_lostTimer.start(); - m_linkType = LINK_YSF; } } @@ -552,6 +577,7 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) if (m_linkType == LINK_FCS) m_fcsNetwork->writeUnlink(3U); + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); m_linkType = LINK_NONE; @@ -560,6 +586,7 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) bool ok = m_fcsNetwork->writeLink(id); if (ok) { + m_current = id; m_inactivityTimer.start(); m_lostTimer.start(); m_linkType = LINK_FCS; @@ -577,9 +604,9 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_NONE; } if (m_linkType == LINK_FCS) { @@ -588,9 +615,9 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->clearDestination(); + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_NONE; } break; @@ -651,39 +678,40 @@ std::string CYSFGateway::calculateLocator() void CYSFGateway::startupLinking() { - std::string startup = m_conf.getNetworkStartup(); - bool revert = m_conf.getNetworkRevert(); - - if (!startup.empty()) { - if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { - LogMessage("Automatic (re-)connection to %s", startup.c_str()); - + if (!m_startup.empty()) { + if (m_startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { + m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); m_linkType = LINK_NONE; - bool ok = m_fcsNetwork->writeLink(startup); + bool ok = m_fcsNetwork->writeLink(m_startup); if (ok) { - if (!revert) - m_inactivityTimer.start(); + LogMessage("Automatic (re-)connection to %s", m_startup.c_str()); + + m_current = m_startup; + m_inactivityTimer.start(); m_lostTimer.start(); m_linkType = LINK_FCS; } else { - LogMessage("Unknown reflector - %s", startup.c_str()); + LogMessage("Unknown reflector - %s", m_startup.c_str()); } } else if (m_ysfNetwork != NULL) { - CYSFReflector* reflector = m_wiresX->getReflector(startup); + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + + CYSFReflector* reflector = m_wiresX->getReflector(m_startup); if (reflector != NULL) { LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); - if (!revert) - m_inactivityTimer.start(); - + m_current = m_startup; + m_inactivityTimer.start(); m_lostTimer.start(); - m_linkType = LINK_YSF; } } diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 5e71b75..7b05afb 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -53,6 +53,8 @@ private: CYSFNetwork* m_ysfNetwork; CFCSNetwork* m_fcsNetwork; LINK_TYPE m_linkType; + std::string m_current; + std::string m_startup; bool m_exclude; CTimer m_inactivityTimer; CTimer m_lostTimer; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 16b41af..b6c82f6 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -37,7 +37,7 @@ Description=APRS Description [Network] # Startup=FCS00120 InactivityTimeout=10 -# Revert=0 +Revert=0 Debug=0 [YSF Network] From 64db730870d8d97c9a5cf35ab09cb0c123f625d0 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 23 Feb 2018 08:06:54 +0000 Subject: [PATCH 12/20] Blank out the DTMF tones. --- YSFGateway/DTMF.cpp | 10 ++++++++-- YSFGateway/DTMF.h | 6 +++--- YSFGateway/YSFGateway.cpp | 2 +- YSFGateway/YSFGateway.h | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index de30b72..35b95f7 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -42,6 +42,8 @@ const unsigned char DTMF_VD2_SYMD[] = { 0x11U, 0x10U, 0x20U, 0x20U, 0x11U, 0x01U const unsigned char DTMF_VD2_SYMS[] = { 0x00U, 0x23U, 0x02U, 0x02U, 0x11U, 0x10U, 0x10U, 0x01U, 0x22U, 0x62U, 0x04U }; const unsigned char DTMF_VD2_SYMH[] = { 0x00U, 0x22U, 0x00U, 0x20U, 0x11U, 0x11U, 0x10U, 0x00U, 0x22U, 0x62U, 0x04U }; +const unsigned char VD2_SILENCE[] = { 0x7BU, 0xB2U, 0x8EU, 0x43U, 0x36U, 0xE4U, 0xA2U, 0x39U, 0x78U, 0x49U, 0x33U, 0x68U, 0x33U }; + CDTMF::CDTMF() : m_data(), m_command(), @@ -56,7 +58,7 @@ CDTMF::~CDTMF() { } -WX_STATUS CDTMF::decodeVDMode2(const unsigned char* payload, bool end) +WX_STATUS CDTMF::decodeVDMode2(unsigned char* payload, bool end) { assert(payload != NULL); @@ -71,7 +73,7 @@ WX_STATUS CDTMF::decodeVDMode2(const unsigned char* payload, bool end) return WXS_NONE; } -WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) +WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end) { // DTMF begins with these byte values if (!end && (ambe[0] & DTMF_VD2_MASK[0]) == DTMF_VD2_SIG[0] && (ambe[1] & DTMF_VD2_MASK[1]) == DTMF_VD2_SIG[1] && @@ -127,6 +129,10 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) else if (sym0 == DTMF_VD2_SYMH[0] && sym1 == DTMF_VD2_SYMH[1] && sym2 == DTMF_VD2_SYMH[2] && sym3 == DTMF_VD2_SYMH[3] && sym4 == DTMF_VD2_SYMH[4] && sym5 == DTMF_VD2_SYMH[5] && sym6 == DTMF_VD2_SYMH[6] && sym7 == DTMF_VD2_SYMH[7] && sym8 == DTMF_VD2_SYMH[8] && sym9 == DTMF_VD2_SYMH[9] && sym10 == DTMF_VD2_SYMH[10]) c = '#'; + // Blank out the DTMF tones. + if (c != ' ') + ::memcpy(ambe, VD2_SILENCE, 13U); + if (c == m_lastChar) { m_pressCount++; } else { diff --git a/YSFGateway/DTMF.h b/YSFGateway/DTMF.h index f73dfb9..8410505 100644 --- a/YSFGateway/DTMF.h +++ b/YSFGateway/DTMF.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ public: CDTMF(); ~CDTMF(); - WX_STATUS decodeVDMode2(const unsigned char* payload, bool end); + WX_STATUS decodeVDMode2(unsigned char* payload, bool end); std::string getReflector(); @@ -42,7 +42,7 @@ private: unsigned int m_pressCount; char m_lastChar; - WX_STATUS decodeVDMode2Slice(const unsigned char* ambe, bool end); + WX_STATUS decodeVDMode2Slice(unsigned char* ambe, bool end); WX_STATUS validate() const; }; diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 61cabb4..25b2adc 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -523,7 +523,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u } } -void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt) +void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) { assert(buffer != NULL); diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 7b05afb..d401565 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -62,7 +62,7 @@ private: void startupLinking(); std::string calculateLocator(); void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); - void processDTMF(const unsigned char* buffer, unsigned char dt); + void processDTMF(unsigned char* buffer, unsigned char dt); void createWiresX(CYSFNetwork* rptNetwork); void createGPS(); }; From c17ffdbb89d74cb74f178af10021bcc0349169d8 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 26 Feb 2018 19:05:34 +0000 Subject: [PATCH 13/20] Bug fixes mostly, --- YSFGateway/DTMF.cpp | 27 ++++++++++---------- YSFGateway/FCSNetwork.cpp | 53 +++++++++++++++++---------------------- YSFGateway/FCSNetwork.h | 1 - YSFGateway/YSFGateway.cpp | 15 +++++++---- 4 files changed, 46 insertions(+), 50 deletions(-) diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index 35b95f7..fe4f950 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -167,30 +167,27 @@ WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end) WX_STATUS CDTMF::validate() const { size_t length = m_command.length(); - if (length != 3U && length != 4U && length != 6U) - return WXS_NONE; - char first = m_command.at(0U); - if (first != '#' && first != 'A') - return WXS_NONE; - if (length == 3U) { - for (unsigned int i = 1U; i <= 3U; i++) { - if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + if (length == 1U && first == '#') { + return WXS_DISCONNECT; + } else if (length == 3U && first == 'A') { + for (unsigned int i = 1U; i < 3U; i++) { + if (m_command.at(i) < '0' || m_command.at(i) > '9') return WXS_NONE; } return WXS_CONNECT_FCS; - } else if (length == 4U) { - for (unsigned int i = 1U; i <= 4U; i++) { - if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + } else if (length == 4U && first == 'A') { + for (unsigned int i = 1U; i < 4U; i++) { + if (m_command.at(i) < '0' || m_command.at(i) > '9') return WXS_NONE; } return WXS_CONNECT_FCS; - } else { - for (unsigned int i = 1U; i <= 6U; i++) { - if (m_command.at(1U) < '0' || m_command.at(1U) > '9') + } else if (length == 6U && first == '#') { + for (unsigned int i = 1U; i < 6U; i++) { + if (m_command.at(i) < '0' || m_command.at(i) > '9') return WXS_NONE; } @@ -199,6 +196,8 @@ WX_STATUS CDTMF::validate() const return WXS_CONNECT_YSF; } + + return WXS_NONE; } std::string CDTMF::getReflector() diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index a2529ce..4b64c89 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -33,13 +33,12 @@ CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigne m_socket(port), m_debug(debug), m_address(), -m_port(0U), m_ping(NULL), m_info(NULL), m_reflector(), m_buffer(1000U, "FCS Network Buffer"), m_n(0U), -m_pingTimer(1000U, 5U), +m_pingTimer(1000U, 0U, 800U), m_state(FCS_UNLINKED) { m_info = new unsigned char[100U]; @@ -73,9 +72,6 @@ bool CFCSNetwork::open() void CFCSNetwork::clearDestination() { - m_address.s_addr = INADDR_NONE; - m_port = 0U; - m_pingTimer.stop(); m_state = FCS_UNLINKED; @@ -85,9 +81,6 @@ void CFCSNetwork::write(const unsigned char* data) { assert(data != NULL); - if (m_port == 0U) - return; - if (m_state != FCS_LINKED) return; @@ -99,12 +92,12 @@ void CFCSNetwork::write(const unsigned char* data) if (m_debug) CUtils::dump(1U, "FCS Network Data Sent", buffer, 130U); - m_socket.write(buffer, 130U, m_address, m_port); + m_socket.write(buffer, 130U, m_address, FCS_PORT); } bool CFCSNetwork::writeLink(const std::string& reflector) { - if (m_port == 0U) { + if (m_state != FCS_LINKED) { std::string name = reflector.substr(0U, 6U); if (m_addresses.count(name) == 0U) { LogError("Unknown FCS reflector - %s", name.c_str()); @@ -118,32 +111,25 @@ bool CFCSNetwork::writeLink(const std::string& reflector) } } - m_port = FCS_PORT; - m_reflector = reflector; - ::memcpy(m_ping + 10U, m_reflector.c_str(), 8U); - writePing(); + m_state = FCS_LINKING; m_pingTimer.start(); - m_state = FCS_LINKING; + writePing(); return true; } void CFCSNetwork::writeUnlink(unsigned int count) { - if (m_port == 0U) + if (m_state != FCS_LINKED) return; for (unsigned int i = 0U; i < count; i++) - m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port); - - m_pingTimer.stop(); - - m_state = FCS_UNLINKED; + m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, FCS_PORT); } void CFCSNetwork::clock(unsigned int ms) @@ -156,7 +142,7 @@ void CFCSNetwork::clock(unsigned int ms) if (length <= 0) return; - if (m_port == 0U) + if (m_state == FCS_UNLINKED) return; m_pingTimer.clock(ms); @@ -165,18 +151,20 @@ void CFCSNetwork::clock(unsigned int ms) m_pingTimer.start(); } - if (address.s_addr != m_address.s_addr || port != m_port) + if (address.s_addr != m_address.s_addr || port != FCS_PORT) return; if (m_debug) CUtils::dump(1U, "FCS Network Data Received", buffer, length); if (length == 7) { + LogMessage("Linked to %s", m_reflector.c_str()); m_state = FCS_LINKED; writeInfo(); } if (length == 10 && m_state == FCS_LINKING) { + LogMessage("Linked to %s", m_reflector.c_str()); m_state = FCS_LINKED; writeInfo(); } @@ -201,17 +189,22 @@ unsigned int CFCSNetwork::read(unsigned char* data) // Pass pings up to the gateway to reset the lost timer. if (len == 10U) { m_buffer.getData(data, len); - return 10U; + + ::memset(data + 0U, ' ', 14U); + ::memcpy(data + 0U, "YSFP", 4U); + ::memcpy(data + 4U, m_reflector.c_str(), 8U); + + return 14U; } unsigned char buffer[130U]; m_buffer.getData(buffer, len); - ::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U); + ::memcpy(data + 0U, "YSFD ALL ", 35U); ::memcpy(data + 35U, buffer, 120U); // Put the reflector name as the via callsign. - ::memcpy(data + 4U, buffer + 121U, 8U); + ::memcpy(data + 4U, m_reflector.c_str(), 8U); data[34U] = m_n; m_n += 2U; @@ -228,22 +221,22 @@ void CFCSNetwork::close() void CFCSNetwork::writeInfo() { - if (m_port == 0U) + if (m_state != FCS_LINKED) return; if (m_debug) CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U); - m_socket.write(m_info, 100U, m_address, m_port); + m_socket.write(m_info, 100U, m_address, FCS_PORT); } void CFCSNetwork::writePing() { - if (m_port == 0U) + if (m_state == FCS_UNLINKED) return; if (m_debug) CUtils::dump(1U, "FCS Network Data Sent", m_ping, 25U); - m_socket.write(m_ping, 25U, m_address, m_port); + m_socket.write(m_ping, 25U, m_address, FCS_PORT); } diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index c2a6f21..11ea3f2 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -59,7 +59,6 @@ private: CUDPSocket m_socket; bool m_debug; in_addr m_address; - unsigned int m_port; unsigned char* m_ping; unsigned char* m_info; std::string m_reflector; diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 25b2adc..d24527b 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -564,11 +564,16 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) } break; case WXS_CONNECT_FCS: { - std::string id = m_dtmf.getReflector(); - if (id.length() == 2U) - id = "FCS00" + id.at(0U) + std::string("0") + id.at(1U); - else - id = "FCS00" + id.at(0U) + id.at(1U) + id.at(2U); + std::string raw = m_dtmf.getReflector(); + std::string id = "FCS00"; + if (raw.length() == 2U) { + id += raw.at(0U) + std::string("0") + raw.at(1U); + } else if (raw.length() == 3U) { + id += raw; + } else { + LogWarning("Nonsense from the DTMF decoder - \"%s\"", raw.c_str()); + return; + } if (m_linkType == LINK_YSF) { m_ysfNetwork->writeUnlink(3U); From c85aa2c9f328f3b04c2654dec0d1c855e57fc522 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 26 Feb 2018 19:12:26 +0000 Subject: [PATCH 14/20] Add sequence number reset code. --- YSFGateway/FCSNetwork.cpp | 22 ++++++++++++++++------ YSFGateway/FCSNetwork.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 4b64c89..a9e52b8 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -39,6 +39,7 @@ m_reflector(), m_buffer(1000U, "FCS Network Buffer"), m_n(0U), m_pingTimer(1000U, 0U, 800U), +m_resetTimer(1000U, 1U), m_state(FCS_UNLINKED) { m_info = new unsigned char[100U]; @@ -73,6 +74,7 @@ bool CFCSNetwork::open() void CFCSNetwork::clearDestination() { m_pingTimer.stop(); + m_resetTimer.stop(); m_state = FCS_UNLINKED; } @@ -134,6 +136,18 @@ void CFCSNetwork::writeUnlink(unsigned int count) void CFCSNetwork::clock(unsigned int ms) { + m_pingTimer.clock(ms); + if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { + writePing(); + m_pingTimer.start(); + } + + m_resetTimer.clock(ms); + if (m_resetTimer.isRunning() && m_resetTimer.hasExpired()) { + m_n = 0U; + m_resetTimer.stop(); + } + unsigned char buffer[BUFFER_LENGTH]; in_addr address; @@ -145,12 +159,6 @@ void CFCSNetwork::clock(unsigned int ms) if (m_state == FCS_UNLINKED) return; - m_pingTimer.clock(ms); - if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { - writePing(); - m_pingTimer.start(); - } - if (address.s_addr != m_address.s_addr || port != FCS_PORT) return; @@ -197,6 +205,8 @@ unsigned int CFCSNetwork::read(unsigned char* data) return 14U; } + m_resetTimer.start(); + unsigned char buffer[130U]; m_buffer.getData(buffer, len); diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 11ea3f2..486b26c 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -66,6 +66,7 @@ private: std::map m_addresses; unsigned char m_n; CTimer m_pingTimer; + CTimer m_resetTimer; FCS_STATE m_state; void writeInfo(); From 253af16694b80f2928a1c2d910180ff45f372a8f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 27 Feb 2018 07:19:22 +0000 Subject: [PATCH 15/20] Add sanity checks to the DTMF code. --- YSFGateway/DTMF.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index fe4f950..f08b2da 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -166,28 +166,34 @@ WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end) WX_STATUS CDTMF::validate() const { + if (m_command.empty()) + return WXS_NONE; + size_t length = m_command.length(); - char first = m_command.at(0U); + char first = m_command.at(0U); if (length == 1U && first == '#') { return WXS_DISCONNECT; } else if (length == 3U && first == 'A') { for (unsigned int i = 1U; i < 3U; i++) { - if (m_command.at(i) < '0' || m_command.at(i) > '9') + char c = m_command.at(i); + if (c < '0' || c > '9') return WXS_NONE; } return WXS_CONNECT_FCS; } else if (length == 4U && first == 'A') { for (unsigned int i = 1U; i < 4U; i++) { - if (m_command.at(i) < '0' || m_command.at(i) > '9') + char c = m_command.at(i); + if (c < '0' || c > '9') return WXS_NONE; } return WXS_CONNECT_FCS; } else if (length == 6U && first == '#') { for (unsigned int i = 1U; i < 6U; i++) { - if (m_command.at(i) < '0' || m_command.at(i) > '9') + char c = m_command.at(i); + if (c < '0' || c > '9') return WXS_NONE; } @@ -205,6 +211,9 @@ std::string CDTMF::getReflector() std::string command = m_command; reset(); + if (command.empty()) + return ""; + return command.substr(1U); } From 63fa0a2cda17a6538ff85177ab05eb91994627cb Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 27 Feb 2018 08:02:02 +0000 Subject: [PATCH 16/20] Reduce logging messages. --- YSFGateway/FCSNetwork.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index a9e52b8..4fae3d6 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -166,7 +166,8 @@ void CFCSNetwork::clock(unsigned int ms) CUtils::dump(1U, "FCS Network Data Received", buffer, length); if (length == 7) { - LogMessage("Linked to %s", m_reflector.c_str()); + if (m_state == FCS_LINKING) + LogMessage("Linked to %s", m_reflector.c_str()); m_state = FCS_LINKED; writeInfo(); } From 53e6c5dd3d5a33f91c5643d479ed246cd347d862 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 27 Feb 2018 18:14:06 +0000 Subject: [PATCH 17/20] Clean up the code and reformat the visible FCSxxxxx string. --- YSFGateway/FCSNetwork.cpp | 20 ++++++++++++-------- YSFGateway/FCSNetwork.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 4fae3d6..3d2c0bf 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -36,6 +36,7 @@ m_address(), m_ping(NULL), m_info(NULL), m_reflector(), +m_print(), m_buffer(1000U, "FCS Network Buffer"), m_n(0U), m_pingTimer(1000U, 0U, 800U), @@ -114,7 +115,9 @@ bool CFCSNetwork::writeLink(const std::string& reflector) } m_reflector = reflector; - ::memcpy(m_ping + 10U, m_reflector.c_str(), 8U); + ::memcpy(m_ping + 10U, reflector.c_str(), 8U); + + m_print = reflector.substr(0U, 6U) + "-" + reflector.substr(6U); m_state = FCS_LINKING; @@ -167,18 +170,18 @@ void CFCSNetwork::clock(unsigned int ms) if (length == 7) { if (m_state == FCS_LINKING) - LogMessage("Linked to %s", m_reflector.c_str()); + LogMessage("Linked to %s", m_print.c_str()); m_state = FCS_LINKED; writeInfo(); } if (length == 10 && m_state == FCS_LINKING) { - LogMessage("Linked to %s", m_reflector.c_str()); + LogMessage("Linked to %s", m_print.c_str()); m_state = FCS_LINKED; writeInfo(); } - if (length == 10 || length == 130) { + if (length == 7 || length == 10 || length == 130) { unsigned char len = length; m_buffer.addData(&len, 1U); m_buffer.addData(buffer, len); @@ -196,12 +199,12 @@ unsigned int CFCSNetwork::read(unsigned char* data) m_buffer.getData(&len, 1U); // Pass pings up to the gateway to reset the lost timer. - if (len == 10U) { + if (len != 130U) { m_buffer.getData(data, len); ::memset(data + 0U, ' ', 14U); ::memcpy(data + 0U, "YSFP", 4U); - ::memcpy(data + 4U, m_reflector.c_str(), 8U); + ::memcpy(data + 4U, m_print.c_str(), 8U); return 14U; } @@ -211,11 +214,12 @@ unsigned int CFCSNetwork::read(unsigned char* data) unsigned char buffer[130U]; m_buffer.getData(buffer, len); - ::memcpy(data + 0U, "YSFD ALL ", 35U); + ::memset(data + 0U, ' ', 35U); + ::memcpy(data + 0U, "YSFD", 4U); ::memcpy(data + 35U, buffer, 120U); // Put the reflector name as the via callsign. - ::memcpy(data + 4U, m_reflector.c_str(), 8U); + ::memcpy(data + 4U, m_print.c_str(), 9U); data[34U] = m_n; m_n += 2U; diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 486b26c..0dd0d18 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -62,6 +62,7 @@ private: unsigned char* m_ping; unsigned char* m_info; std::string m_reflector; + std::string m_print; CRingBuffer m_buffer; std::map m_addresses; unsigned char m_n; From fcc179d5f61d90c153f74fa062f54e8f31aba4cc Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 28 Feb 2018 18:50:37 +0000 Subject: [PATCH 18/20] Bump the version date. --- YSFGateway/Version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YSFGateway/Version.h b/YSFGateway/Version.h index b6885be..f3baaa8 100644 --- a/YSFGateway/Version.h +++ b/YSFGateway/Version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20170719"; +const char* VERSION = "20180228"; #endif From f63c6069de375f6d9d75405d78ef9a6924c258b2 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 4 Mar 2018 11:40:25 +0000 Subject: [PATCH 19/20] Update the YSF Hosts file. --- YSFGateway/YSFHosts.txt | 360 ++++++++++++++++++++++------------------ 1 file changed, 195 insertions(+), 165 deletions(-) diff --git a/YSFGateway/YSFHosts.txt b/YSFGateway/YSFHosts.txt index abd17e8..bcfb4d5 100644 --- a/YSFGateway/YSFHosts.txt +++ b/YSFGateway/YSFHosts.txt @@ -1,165 +1,195 @@ -65702;0 OE-Austria;Official;94.199.172.148;42000;001 -88236;1004 DMR;DRM C4FM CROSS;210.178.113.173;42000;000 -74652;119-YSF;TG45004 XLX170;125.129.207.86;42000;002 -89803;A.O.T. Roma;OndaTelematica;31.14.140.230;42000;000 -02034;Alabama-Link;Alabama-Link;199.119.98.174;42000;029 -64230;America-RC;YSF-TO-WIRES-X;71.209.204.22;42000;006 -38654;ARGENTINA;C4FM Team;212.237.3.87;42000;005 -59330;ARRGUS Array;Florida USA;96.94.7.200;42000;000 -42586;ARRGUS_ArrayN;Back up server;64.137.194.85;42000;000 -25223;AT Austria OE1;OE1PHS;77.117.224.174;42000;002 -00396;AT Austria OE3;OE3AAS;77.118.186.2;42100;001 -55693;AT C4FM Austria;YSF;89.185.97.38;42000;008 -04201;AU YSF001;1st WW YSF;104.167.114.230;42000;012 -93760;BE YSF-Vlaandere;C4FM Vlaandere;81.95.126.168;42000;004 -79520;BE YSF-Wallonie;C4FM Wallon;51.255.193.63;42000;004 -67661;BG Bulgaria;Sysop: LZ1LCD;95.43.222.149;42000;000 -47573;BM-EA-TG914;BM-EA-TG914;104.223.70.166;42000;003 -14341;BM-TG-208;BrMstr TG208;51.254.126.212;42000;002 -30745;BM-TG-2080;BrMstr TG2080;51.254.126.212;42080;001 -00872;BM-TG-20820;BrMstr TG20820;51.254.126.212;42020;001 -52846;BM-TG-20859;BrMstr TG20859;51.254.126.212;42059;002 -39552;BM-TG-2087;BrMstr TG2087;51.254.126.212;42007;001 -93206;BM-TG-2088;BrMstr TG2088;51.254.126.212;42008;001 -35402;BM-TG-2089;BrMstr TG2089;51.254.126.212;42009;001 -36096;BR YSF724;C4FM - DV Braz;66.55.64.14;42000;002 -85044;C4FM-SEOUL;TG45004 XLX170;121.162.91.45;42000;004 -77353;CA Canada;C4FM Ontario;144.217.241.23;42100;006 -49473;CA QUEBEC;QC FR Fusion;64.34.60.44;42000;000 -52796;CH JOTA;Jota CH;157.161.57.65;42001;000 -59050;CL CE3FCM;ysfreflector;190.161.179.169;42000;000 -80337;CN China #1;C4FM YSF;120.234.41.144;42000;008 -82442;CN China #2;C4FM Guangzhou;218.19.147.38;42000;000 -86319;CN China #3;C4FM;123.58.6.137;42002;026 -30490;CO 4 KILO MIKE;Antioquia;190.159.68.105;43000;000 -04523;CT CATALANA;C4FM Catalunya;85.214.119.76;42000;000 -30549;CT WIRESCAT;C4FM Catalunya;85.214.119.76;42001;005 -26541;CZ Czech;TG2300 DCS019V;80.250.3.114;42000;008 -58770;CZ YSF Praha;YSF CZ;185.32.183.148;42000;000 -80861;DE DL-NORD;AFu-Nord.de;5.45.96.68;42000;000 -54919;DE DL-NORDWEST;Nordwest-DL;91.12.55.157;42000;007 -62829;DE Germany;TG26208;213.202.229.15;42000;031 -10322;DE Germany2;no bridge;213.202.229.15;42001;000 -92469;DE Hessen;SysOP:DL5RFK;193.70.38.68;42000;001 -74154;DE PEGASUS;dl0bza.de;78.46.11.65;42000;014 -20548;DE PEGASUS2;dl0bza.de;78.46.11.65;42001;000 -55966;DE Thueringen;Thueringen;37.26.200.222;42000;001 -94179;Digiland;Italia;212.227.203.37;42000;000 -68785;Digiland_2;Italia;185.206.147.131;42000;000 -68899;Digiland_3;Italia;85.217.170.178;42000;000 -00561;DVSwitch NA;North America;44.103.32.18;42000;000 -94533;EA Distrito 1;Wires X Spain;104.223.72.8;42000;000 -42493;EA Distrito 2;EDT;185.47.129.230;42000;002 -42493;EA Distrito 2;EDT;185.47.129.230;42000;002 -48495;EA Distrito 3;Wires X Spain;89.38.150.252;42000;000 -62980;EA Distrito 4;REM SPAIN;212.237.0.67;42000;001 -39908;EA Distrito 5;YSF EALINK;216.86.147.198;42000;000 -58314;EA Distrito 7;RC Veleta;212.237.11.53;42000;001 -31236;EA DMR+;DMR+ 4370;198.96.90.144;42000;000 -37172;EA Sevilla;Prov Sevilla;204.44.93.190;42000;003 -01439;EMCOM SPAIN;Emergency;212.237.17.133;42000;000 -32027;ES ADER;ASSOCIACIO;80.211.226.198;42000;003 -98529;ES ED2ZAE;Multiporpouse;94.177.237.192;42000;001 -15642;ES REM SPAIN;REM YSF REF;95.39.166.7;42000;000 -60318;ES Wires X;WIRES X SPAIN;80.211.236.189;42000;015 -62659;ES YSF214;C4FM Net;89.36.214.120;42000;000 -08054;FON-Gateway;AllModes-GW;185.109.201.81;42000;001 -60786;FR F1ZLJ (95);Val dOise-ARAM;82.236.81.19;42000;002 -86886;FR Room-ZIT;Room F1ZIT;151.80.143.185;42002;008 -39510;FR wiresxfrance;Wires-X-France;151.80.143.185;42000;000 -83665;FR YSF-Alpes;Rhone-Alpes;217.182.66.229;42000;000 -60284;FR YSF-Alsace;ALS(F) ROOM;91.121.136.94;42000;002 -19531;FR YSF-Bretagne;Bretagne;78.206.208.208;42000;000 -13844;FR YSF-Cappelle;YSF Room F1ZKY;92.188.0.108;42000;002 -58617;FR YSF-France;Fusion France;87.98.132.205;42000;023 -91713;FR YSF-Limouzi;C4FM Limousin;88.174.140.210;42000;000 -46353;FR YSF-Nord;Nord;79.137.74.24;42000;003 -33751;FUSION-ITALY;Italy YSFR;188.213.173.69;42000;001 -91767;GB Fusion Kernow;Fusion SW UK;91.121.101.163;43000;002 -97576;GB N.Ireland;YSF N.Ireland;91.121.101.163;42500;004 -76849;GR YSF202;Fusion Greece;144.76.101.219;42000;006 -25419;Guatemala;CentOS7;74.208.88.137;42000;003 -47247;HB C4FM Basel;CISAR Basel;212.237.33.114;42000;002 -62928;HBLINK EA5GVK;HBLINK EA5GVK;84.127.124.188;42000;000 -98367;HK WTT YSF;No bridge;218.255.238.138;42006;004 -41120;HU Hungary;BM TG2167;213.181.208.141;42100;001 -04251;IE YSF Ireland;Fusion <> DMR;87.44.19.111;42000;011 -94264;IT C4FM ENNA;HAMRADIOENNA #;94.176.6.45;42000;000 -67939;IT C4FM LAZIO;773RadioGroup;93.186.255.126;42000;002 -30483;IT C4FM Lodi;Lombardia;79.54.231.198;42000;002 -51231;IT C4FM NORD;ITALY-NORD;78.47.154.19;42000;006 -19437;IT C4FM Piemonte;DSP Italy;94.177.173.53;42000;004 -64159;IT ITALY-FREE;c4fm bridge;37.187.106.175;42000;003 -82044;IT YSFROOM-ITALY;WIRES-X ITALY;94.177.187.40;42000;012 -67411;IT Zona 4;EmiliaRomagna;212.84.32.29;42000;000 -25383;JP JAPAN;Fusion Japan;202.241.175.133;42000;002 -96455;NL Central;Centraal NL;90.145.156.196;42000;004 -85875;NL Fusion Almere;Flevoland;84.86.62.38;42000;018 -73238;NL Noord;test reflector;44.137.87.82;42000;001 -63539;NL Oost;test reflector;44.137.87.83;42000;002 -73443;NL PI1DAF;Multi Repeater;77.174.30.155;42000;003 -66644;NL YSF amprnet;ampr reflector;44.137.33.52;42000;000 -38627;NL YSF444;Dutch Refl.;188.68.37.51;42000;003 -56254;NO YSF006;Norway;80.89.46.242;42000;009 -88973;NZ NZ750;XLX750 NZ;210.55.201.126;42000;002 -49480;NZ NZXLX;XLX626;202.137.244.157;42000;002 -46031;NZ ZL2VH;ZL2VH YSF;123.255.47.67;42000;002 -37761;OklahomaLink;OklahomaLink;70.189.115.214;42000;004 -00001;Parrot;Parrot;213.202.229.15;42020;000 -25393;PL 4280;YSF/DMR/DCS132;94.246.175.66;42031;002 -98564;PL EmCom;EmCom TG260023;195.26.76.59;42023;001 -29114;PL POLAND;POLAND WiresX;94.246.175.66;42025;005 -38274;PL Poland 21;DMR TG260021;195.26.76.59;42021;001 -04463;PL Poland 22;DMR TG260022;195.26.76.59;42022;001 -55546;PL Silesia;Poland Silesia;188.116.7.66;42001;000 -11533;PL SR8DMR;RTCN Chotycze;94.246.175.66;42029;001 -78099;PL SR8FWD;Wlodawa WiresX;94.246.175.66;42030;001 -91407;PL SR8LUF;Lublin;94.246.175.66;42028;001 -61506;PL SR8UD;Ustrzyki;94.246.175.66;42032;000 -54644;PL SR8UWD;Wlodawa YSF;94.246.175.66;42027;001 -80986;PL YSF260;BM TG260;94.246.175.66;42035;001 -09948;PT YSF009;C4FM-Portugal;109.71.44.237;42000;005 -89355;R.E.E.C.;R.E.E.C.;5.135.137.65;42000;000 -13131;ref.c4fm.se;ref.c4fm.se;176.10.140.161;42000;004 -23116;RO MULTIMODE;BM TG2260;94.176.6.37;42005;002 -99447;RO YSF226;BM TG226;94.176.6.37;42000;004 -00229;RO YSF<->Wires-X;C4FM Reflector;94.176.6.37;42001;002 -40208;SC Scotland;Scottish YSF;13.69.14.204;42000;008 -43699;SE SK7ES;SK7ES Fusion;44.140.236.22;42000;000 -77010;SE SW-Sweden;C4FM;46.236.122.101;52000;000 -07237;TechTalk24;Engineers talk;195.26.76.59;42024;002 -43513;TROJMIASTO;Poland Tricity;195.140.190.58;42000;001 -30743;TW HAMTALK;C4FM @HAMTALK;118.150.164.96;42000;001 -00325;TW YSF886;C4FM Taiwan;118.163.103.178;42000;000 -13201;UK DVMEGA;DVMEGA CHAT;212.237.34.32;42000;013 -93019;UK DVMEGA SH;DVMEGA CHAT SH;212.237.18.27;42000;002 -83087;UK_YSF_BM_UK;UK_Ref_DN_ONLY;91.121.101.163;42000;018 -21988;US AggielandLink;Aggieland Link;71.252.210.227;42000;003 -22647;US BM TG 31254;Carolina Link;52.3.47.55;42000;005 -51512;US BM TG 3137;North Carolina;52.3.47.55;42001;001 -74185;US BM-TG3139;DMR-313960-To-;52.54.69.145;42000;003 -49235;US CKRG;Central Kansas;198.211.109.207;42000;002 -39906;US COLORADO-LINK;Colorado Link;13.78.187.50;42000;006 -84105;US East PA;MMDVM System;173.49.20.45;42005;000 -04162;US GLOBAL DX;Global DX;206.72.198.26;42000;002 -30725;US K7EVR YSF;EVAR Mesa,AZ;72.201.150.71;42000;001 -02912;US Nationwide;United States;174.36.222.36;42000;016 -53594;US Ohio;Ohio;162.243.74.151;42000;001 -62554;US Texas-Nexus;Texas-Nexus;104.2.186.135;42000;022 -80767;US TGIF-BM 31665;US TGIF-BM 316;162.248.92.62;42000;013 -98899;US WolfDen;Massachusetts;100.0.26.120;42000;002 -90943;US YSF 858;YSF SDCA-NZ6D;104.236.156.191;42000;001 -08033;US YSF002;KingsOfDigital;52.10.253.1;42000;001 -91768;US YSF082 NYC;KARG & NB2O;108.21.232.23;42000;002 -23864;US YSF310;K6KD;64.137.191.209;42000;001 -96429;US-KansasLink;Kansas C4FM Re;72.205.226.24;42000;006 -87531;US-QuadNetATL;QuadNet-BM;107.191.121.105;42000;001 -74247;US-RepeaterBook;DMR TG 31419;69.71.127.9;42000;002 -12224;US-YSF-NE;NEW-ENGLAND;54.144.216.63;42000;009 -33386;US-YSF570;NEPA Fusion Sy;104.128.230.153;42000;000 -88051;US-YSF587NYS;YSF-QNetBridge;216.155.157.11;42000;002 -41577;YSF YO W;Fusion Romania;89.122.215.236;42000;003 -91559;YSF-BRAZIL;C4FM-BRAZIL;200.231.36.174;42000;004 -24519;YSF-EA5 SPAIN;Zona EA5;84.127.124.188;42105;006 -93029;YSF004 MI5 SW2;Crossconnect t;44.103.34.3;42000;001 -65576;YSF937;Guri, South Ko;1.240.221.206;42000;000 +65702;0 OE-Austria;Official;94.199.173.123;42000;001;http://c4fm-austria.dyndns.org:46193 +38089;0077;IRLP/DMR Esp;216.21.9.156;42000;000;xe1dvi.crabdance.com/html/index.php +74652;119-YSF;TG45004 XLX170;125.129.207.86;42000;003;http://ysf119.dvham.com/index.php +89803;A.O.T. Roma;OndaTelematica;31.14.140.230;42000;000;http://www.ondatelematica.it +02034;Alabama-Link;Alabama-Link;199.119.98.174;42000;049;http://ysf.alabamalink.info/ +64230;America-RC;YSF-TO-WIRES-X;65.101.7.49;42000;009;http://65.101.7.49 +88060;AREC US FL-727;C4FM Bridge BM;97.76.81.165;42000;000;http://ysf.inerrantenergy.com/ysf/ +38654;ARGENTINA;C4FM Team;212.237.3.87;42000;010;http://ysfargentina.mmdvm.es +59330;ARRGUS Array;Florida USA;96.94.7.200;42000;002;http://ysf.arrg.us +42586;ARRGUS_ArrayN;Back up server;64.137.194.85;42000;001;http://ysf6.arrg.us +25223;AT Austria OE1;OE1PHS;213.47.71.17;42000;004;http://oe1phs.ddns.net/YSFReflector-Dashboard/ +00396;AT Austria OE3;OE3AAS;77.117.158.250;42100;001;http://oe3aas.ddns.net/YSFReflector-Dashboard/ +59911;AT Austria OE8;OE8VIK;62.203.54.167;42000;004;http://oe8vik.ddns.net/YSFReflector-Dashboard +55693;AT C4FM Austria;YSF;89.185.97.38;42000;021;http://c4fm.oevsv.at/ysf +04201;AU YSF001;1st WW YSF;125.63.61.26;42000;018;http://ysf001.duckdns.org +93760;BE YSF-Vlaandere;C4FM Vlaandere;81.95.126.168;42000;003;http://ysf.on4top.be/ysf +79520;BE YSF-Wallonie;C4FM Wallon;51.255.193.63;42000;004;http://www.ysfwallonie.net/ +67661;BG Bulgaria;Sysop: LZ1LCD;95.43.222.149;42000;001;http://fusion.spirka.net +37692;BM TG28412;Test;193.93.24.29;42000;001;http://ysf.ham-dmr.bg/ +47573;BM-EA-TG914;BM-EA-TG914;104.223.70.166;42000;003;http://104.223.70.166/ysf/ +14341;BM-TG-208;BrMstr TG208;51.254.126.212;42000;002; +30745;BM-TG-2080;BrMstr TG2080;51.254.126.212;42080;001; +00872;BM-TG-20820;BrMstr TG20820;51.254.126.212;42020;001; +37594;BM-TG-20845;BrMstr TG20845;51.254.126.212;42045;001; +52846;BM-TG-20859;BrMstr TG20859;51.254.126.212;42059;002; +39552;BM-TG-2087;BrMstr TG2087;51.254.126.212;42007;001; +93206;BM-TG-2088;BrMstr TG2088;51.254.126.212;42008;001; +81116;BM-TG-20883;BrMstr TG20883;51.254.126.212;42083;002; +35402;BM-TG-2089;BrMstr TG2089;51.254.126.212;42009;001; +36096;BR YSF724;C4FM - DV Braz;66.55.64.14;42000;007;http://ysf.dvbrazil.com.br/ +85044;C4FM-SEOUL;TG45004 XLX170;121.162.91.45;42000;008;http://ysfso.dvham.com/indexysf.php +77353;CA Canada;C4FM Ontario;144.217.241.23;42100;007;http://c4fmontario.hopto.org +49473;CA QUEBEC;QC FR Fusion;64.34.60.44;42000;002;http://www.ve2mrc.com/ysfr/index.php +79602;Carolina Link;Carolina Link;52.3.47.55;42000;003;http://52.3.47.55/index.php +30998;CH 228 Swiss;Bridge BM22820;176.10.105.210;42000;005;http://ysf.hb-connect.ch/ +52796;CH JOTA;Jota CH;157.161.57.65;42001;000; +80337;CN China #1;C4FM YSF;120.234.41.144;42000;038;http://ysf.sz790.com:8081/ +82442;CN China #2;W24269/TG46072;116.6.107.115;42006;005;http://ufozhuzi.tpddns.cn:8081/ +09724;CN China #99;YSF Test;103.107.105.251;42000;000;http://ysf.ncwxd.com +40973;CN-China-03;C4FM;123.58.6.137;42000;000;http://123.58.6.137:8088 +30490;CO 4 KILO MIKE;Antioquia;190.159.68.105;42000;000; +04523;CT CATALANA;C4FM Catalunya;85.214.119.76;42000;004;http://ysfcat.ea3hkb.com +30549;CT WIRESCAT;C4FM Catalunya;85.214.119.76;42001;012;http://wirescat.ea3hkb.com +26541;CZ Czech;TG2300 DCS019V;80.250.3.114;42000;009;http://80.250.3.114/index.php +77329;CZ YSF Praha;CZ YSF Praha;185.32.183.148;42000;005;http://185.32.183.148/ysf/ +63382;DAHSOB;DAH / SOB;91.61.232.8;42000;001; +80861;DE DL-NORD;AFu-Nord.de;5.45.96.68;42000;002;http://funk-sh.de +54919;DE DL-NORDWEST;Nordwest-DL;84.140.31.216;42000;017;http://dl-nordwest.spdns.de +62829;DE Germany;TG26208;213.202.229.15;42000;028;https://c4fm.ysfreflector.de/Germany +74154;DE PEGASUS;Multi-Bridge;78.46.11.65;42000;015;https://status.projekt-pegasus.net/ +20548;DE PEGASUS2;Test System;78.46.11.65;42001;000;https://status.projekt-pegasus.net/ +63421;DE Ruhrgebiet;Ruhrgebiet;144.76.12.90;42000;005;http://dg3yjb.beba.re/YSFReflector +15017;DE Saarland;darc-saar.de;213.202.229.220;42000;000;https://c4fm.darc-saar.de/ +95352;DE Twitterrunde;GW BM TG263333;213.202.229.15;42001;004;https://c4fm.ysfreflector.de/Twitterrunde +00561;DVSwitch NA;North America;44.103.32.18;42000;001;http://dvswitch.org/ysfreflector/ +94533;EA Distrito 1;Wires X Spain;212.237.30.36;42000;000;http://ysfdistrito1.mmdvm.es/ +42493;EA Distrito 2;EDT;185.47.129.230;42000;003;http://server.ea2ip.com/ysf/ +48495;EA Distrito 3;Wires X Spain;89.38.150.252;42000;001;http://ysfdistrito3.mmdvm.es/ +62980;EA Distrito 4;REM SPAIN;212.237.0.67;42000;000;http://ysfdistrito4.mmdvm.es/ +39908;EA Distrito 5;YSF EALINK;216.86.147.198;42000;000;http://ysfdistrito5.mmdvm.es/ +58314;EA Distrito 7;RC Veleta;212.237.11.53;42000;009;http://ysfdistrito7.mmdvm.es/ +37172;EA Sevilla;Prov Sevilla;204.44.93.190;42000;004;http://ysfsevilla.mmdvm.es/ +01439;EMCOM SPAIN;Emergency;212.237.17.133;42000;000;http://ysf.emcomspain.xreflector.es/ +32027;ES ADER;ASSOCIACIO;80.211.226.198;42000;002;http://80.211.226.198/index_dashboard.php +18423;ES andalucia-esp;andalucia EA7;94.177.196.120;42000;000;ysfandalucia.ddns.net +26260;ES CORDOBA-ESP;CORDOBA;80.211.131.156;42000;001;http://www.ea7or.es +98529;ES ED2ZAE;Multiporpouse;94.177.237.192;42000;001;http://ysf900.dyndns.org/ysf +15642;ES REM SPAIN;REM YSF REF;213.37.155.58;42000;000;http://rem-esp.es +60318;ES Wires X;WIRES X SPAIN;80.211.236.189;42000;018;http://ysf.xreflector.es/ +86886;FR Room-ZIT;Room F1ZIT;151.80.143.185;42002;009;http://151.80.143.185/zit/YSFReflector-Dashboard/ +39510;FR wiresxfrance;Wires-X-France;151.80.143.185;42000;000;http://151.80.143.185/WXF/YSFReflector-Dashboard/index.php +59495;FR YSF St Amand;St Amand (59);51.15.172.24;42000;002;https://srv.hambox.fr/dashboard/ +83665;FR YSF-Alpes;Rhone-Alpes;217.182.66.229;42000;001;http://ysf-alpes.f4gve.net +60284;FR YSF-Alsace;Room (67-68);91.121.136.94;42000;001;http://c4fm.vulcain.space/ +19531;FR YSF-Bretagne;Bretagne;78.206.208.208;42000;000;http://78.206.208.208:8081/YSFReflector-Dashboard/index.php +13844;FR YSF-Cappelle;YSF Room F1ZKY;92.188.0.108;42000;001;http://ysf.a3rn.org:2626 +58617;FR YSF-France;Fusion France;87.98.132.205;42000;031;http://ysf-france.fr/ +91713;FR YSF-Limouzi;C4FM Limousin;88.174.140.210;42000;001;http://ysf-limousin.dyndns.org:8787 +46353;FR YSF-Nord;Nord;178.32.163.106;42000;003; +33751;FUSION-ITALY;Italy YSFR;188.213.173.69;42000;002;http://c4fm-it.selfip.com/ +91767;GB Fusion Kernow;Fusion SW UK;87.117.229.165;43000;001;http://ysf.mb6cc.co.uk +86111;GB Midlands;YSF Mids GB;86.181.124.242;42021;003; +97576;GB N.Ireland;YSF N.Ireland;87.117.229.165;42500;004; +16710;GB SOUTH WEST;YSF REFLECTOR;31.51.76.253;43000;003;http://g8koe.ddns.net:8000/ +25419;Guatemala;CentOS7;74.208.88.137;42000;005;http://74.208.88.137/YSF/index.php +47247;HB C4FM Basel;CISAR Basel;212.237.33.114;42000;000;http://212.237.33.114/c4fm/index.php +62928;HBLINK EA5GVK;HBLINK EA5GVK;84.127.124.188;42000;000;http://ea5gvk.duckdns.org:84/YSFReflector +29256;HK-WTT-YSF;BM TG460790;218.255.238.138;42006;003;http://218.255.238.138/Dashboard/ +41120;HU Hungary;BM TG216;185.187.75.192;42100;001;http://brandmeister.hu/ysfref/ +04251;IE YSF Ireland;Fusion <> DMR;87.44.19.111;42000;009; +94264;IT C4FM ENNA;HAMRADIOENNA #;94.176.6.45;42001;000;http://ysf.hamradioenna.it +67939;IT C4FM LAZIO;773RadioGroup;93.186.255.126;42000;001;http://ysf.iz0rin.it/ysf/ +30483;IT C4FM Lodi;Lombardia;79.51.62.21;42000;001;http://ysf.iw2gob.it/c4fm/index.php +51231;IT C4FM NORD;ITALY-NORD;78.47.154.19;42000;006;http://italy-nord.dyndns.biz/dashboard/index.php +19437;IT C4FM Piemonte;DSP Italy;94.177.173.53;42000;003;http://94.177.173.53:8085/c4fm/index.php +14115;IT C4FM PUGLIA;C4FM Puglia It;94.177.164.25;42000;000;http://c4fm-puglia.iz7auh.net/YSFReflector-Dashboard/index.php +12624;IT C4FM SUD;ITALY-SUD;212.237.59.103;42000;000;http://c4fm-italy-sud.iz7auh.net/YSFReflector-Dashboard/index.php +47946;IT Digiland;Italia;212.227.203.37;42000;000;http://212.227.203.37/ysf/index.php +82915;IT Digiland 2;Italia;185.203.118.135;42000;000;http://185.203.118.135/ysf +30942;IT Digiland 3;Italia;85.217.170.178;42000;000;http://85.217.170.178/ +64120;IT DSTAR-LINK;LINK DSTAR;80.211.156.219;42000;002;http://80.211.156.219/index.php +58288;IT GDO FUSION;C4FM Ossola;78.134.125.81;42001;000;http://iz1zpj.ddns.net/c4fm/index.php +64159;IT ITALY-FREE;c4fm bridge;37.187.106.175;42000;002; +34697;IT SICILIA;C4FM REFLECTOR;94.176.6.45;42000;004;http://sicilia.c4fm.it +82044;IT YSFROOM-ITALY;WIRES-X ITALY;94.177.187.40;42000;029;http://ysfroomitaly.iw2gob.it/c4fm/index.php +67411;IT Zona 4;EmiliaRomagna;212.84.32.29;42000;001; +70220;ITALY-I5-PT;C4FM Pistoia;95.235.200.175;42000;001;http://iu5hju.ddns.net/index.php +70542;Japan ShounanYSF;Japan ShounanY;133.130.114.45;42000;001;http://shounandstar.dip.jp/ysf/ +25383;JP JAPAN;Fusion Japan;122.222.1.50;42000;010;http://c4fm.owari.biz/ysfref/ +13870;KAVKAZ;RUS, North Cau;37.18.35.2;42000;002; +20457;Miami-LATINO;C4FM;80.211.175.168;42000;000;http://80.211.175.168/ +23944;MX Fusion Mexico;Fusion Mexico;200.57.9.10;42000;002;http://200.57.9.10 +11714;MY Malaysia Net;Malaysia Net;150.129.184.54;42000;001;http://ysf.myaprs.my/ysf/index.php +96455;NL Central;Centraal NL;90.145.156.196;42000;024;http://c4fm.pa7lim.nl/ +85875;NL Fusion Almere;Flevoland;84.86.62.38;42000;002;http://c4fm-pe1gdf.nl +92034;NL ItaNed;Test reflector;83.162.231.214;42000;000; +73238;NL Noord;test reflector;44.137.87.82;42000;001;http://44.137.87.82/index.php +63539;NL Oost;test reflector;44.137.87.83;42000;002;http://44.137.87.83/index.php +73443;NL PI1DAF;Multi Repeater;77.174.30.155;42000;002;http://pd0poh.ddns.net +66644;NL YSF amprnet;ampr reflector;44.137.33.52;42000;000;http://44.137.33.52/index.php +38627;NL YSF444;Dutch Refl.;188.68.37.51;42000;001;http://ysf444.pa3dfn.nl +56254;NO YSF006;Norway;80.89.46.242;42000;015; +46031;NZ ZL2VH;ZL2VH YSF;123.255.47.67;42000;006;http://123.255.47.67:84 +48038;Ohio-Link;Ohio-Link;75.76.129.38;42000;006; +37761;OklahomaLink;Wires21733,BM3;70.189.115.214;42000;006;http://oklahomalink.duckdns.org:2080 +00001;Parrot;Parrot;213.202.229.15;42020;000; +25393;PL 4280;YSF/DMR/DCS132;94.246.175.66;42031;003;https://brandmeister.network/?page=lh&DestinationID=260080 +29114;PL POLAND;POLAND WiresX;94.246.175.66;42025;015;https://brandmeister.network/?page=lh&DestinationID=260042 +55546;PL Silesia;Poland Silesia;188.116.7.66;42001;001;http://ysfsilesia.pzk.pl/ +38691;PL SR4H;SR4H-ROOM;91.244.185.128;42000;002; +11533;PL SR8DMR;RTCN Chotycze;94.246.175.66;42029;001;http://ysf016.wiresx.pl:8081/sr8dmr/ +78099;PL SR8FWD;Wlodawa WiresX;94.246.175.66;42030;001;http://sr8fwd.wiresx.pl +79009;PL SR8K;Dubiecko;94.246.175.66;42032;001;http://ysf016.wiresx.pl:8081/sr8k/ +91407;PL SR8LUF;Lublin;94.246.175.66;42028;001;http://ysf016.wiresx.pl:8081/sr8luf/ +87318;PL SR8UVC;Chotylow;94.246.175.66;42034;001; +54644;PL SR8UWD;Wlodawa YSF;94.246.175.66;42027;001;http://sr8uwd.wiresx.pl +74470;PL SR9FSR;Wola YSF;188.116.7.66;42002;001;http://ysfsr9fsr.pzk.pl/ +80986;PL YSF260;BM TG260;94.246.175.66;42035;003;http://ysf016.wiresx.pl:8081/260/ +09948;PT YSF009;C4FM-Portugal;109.71.44.237;42000;004;http://c4fm.from-ct.com/ysf/ +89355;R.E.E.C.;R.E.E.C.;5.135.137.65;42000;001;http://www.reec.be/ysf +13131;ref.c4fm.se;ref.c4fm.se;176.10.140.161;42000;005;http://ref.c4fm.se +07931;RO YO QSO Party;C4FM Reflector;94.176.6.37;42001;001;http://wiresx.226.ro/ +50662;RO-CafeGratis;BM TG2260;94.176.6.37;42005;001;http://ysf.cafegratis.club +06955;Salento Digital;-;185.203.118.8;42000;001;http://185.203.118.8/ +40208;SC Scotland;Scottish YSF;13.69.14.204;42000;012;http://c4fm.dvscotland.net +43699;SE SK7ES;SK7ES Fusion;44.140.236.22;42000;002;http://ysf.sm7.hamnet.nu +77010;SE SW-Sweden;C4FM;46.236.122.101;52000;000;http://sm4wdq.hopto.org:9999/ +48857;SI-Slovenia;TG293;84.52.159.10;42000;004;http://xlx511.ddns.net:46193/index.php +94513;TH YSF520;C4FM THAILAND;119.59.125.192;42000;004;http://ysf.dtdxa.com +43513;TROJMIASTO;Poland Tricity;195.140.190.58;42000;001;http://ysftricity.ham-dmr.pl +30743;TW HAMTALK;C4FM @HAMTALK;118.150.164.96;42000;003;http://www.hamtalk.net/ysfr +00325;TW YSF886;C4FM Taiwan;118.163.103.178;42000;004;http://xlx886.metropit.net/ysfr/ +13201;UK DVMEGA;DVMEGA CHAT;212.237.34.32;42000;007;http://c4fm.dvmega.co.uk +93019;UK DVMEGA SH;DVMEGA CHAT SH;212.237.18.27;42000;002;http://212.237.18.27/ysf/ +83087;UK_YSF_BM_UK;UK_Ref_DN_ONLY;87.117.229.171;42000;030; +21988;US AggielandLink;Aggieland Link;71.252.210.227;42000;001;http://www.aggielandlink.com/Dashboard +51512;US BM TG 3137;North Carolina;52.3.47.55;42001;002;http://52.3.47.55/NC/index.php +93196;US BM TG 31444;RI Digital Hub;54.68.216.180;42001;003;http://southeast.digitallink.us/RI/ +49235;US CKRG;Central Kansas;198.211.109.207;42000;004; +39906;US COLORADO-LINK;Colorado Link;13.78.187.50;42000;012;http://cartradioysf.ae2l.net +84105;US East PA;MMDVM System;173.49.20.45;42005;001;http://www.wb0yle.com:8484 +04162;US GLOBAL DX;Global DX;206.72.198.26;42000;005;http://206.72.198.26/ysf +83132;US Illinois Link;Illinois Link;74.208.235.115;42000;007;http://74.208.235.115/index.php +80374;US K4BUM;K4BUM-Group;35.196.9.211;42000;002; +99597;US Kingsland;Kingsland GA;54.68.216.180;42000;003;http://w1kfr.from-ga.com/GA/index.php +02912;US Nationwide;United States;174.36.222.36;42000;035;http://ysf.kc2idb.net/index.php +48139;US nature coast;nature coast;47.206.21.6;42000;004;http://47.206.21.6:81 +85788;US NJ EXP;US NJ EXP;64.137.243.122;42000;000;http://xrf.njpaasterisk.org +83242;US NW-Ohio;YSF-WiresX-284;52.54.69.145;42000;001;http://ysf.k8xg.com +53594;US Ohio;Ohio;162.243.74.151;42000;001;http://ysf.n8qq.com +09585;US RFIT;YSF TO DMR;73.233.224.103;42000;003; +84398;US SADRC;SanAntonioDRC;71.78.10.76;42000;012; +62554;US Texas-Nexus;Texas-Nexus;104.2.186.135;42000;020;http://ysf.texas-nexus.dyndns.org/ysf/ +80767;US TGIF-BM 31665;US TGIF-BM 316;162.248.92.62;42000;011;http://n2nuo.com/ysf/index.php +76864;US Triangle NC;Triangle NC;192.223.28.198;42000;002;http://ysf.trianglenc.net +98899;US WolfDen;Massachusetts;100.0.26.120;42000;001;http://wolfden.ddnsgeek.com:42080 +38268;US YSF 012;PAPA YSF 012;209.112.244.28;42000;004;http://ysfr012.papasys.com +90943;US YSF 858;YSF SDCA-NZ6D;104.236.156.191;42000;000;http://nz6d.dx40.com/ysf +08033;US YSF002;KingsOfDigital;52.10.253.1;42000;002;http://ysf002.dstar.club +91768;US YSF082 NYC;KARG & NB2O;108.21.232.23;42000;001;http://ysf082.pungsan.com/ +23864;US YSF310;K6KD;64.137.191.209;42000;000;http://ysf310.xrefl.net +96429;US-KansasLink;Kansas C4FM Re;23.119.252.30;42000;006;http://kansas-ysf.dyndns.org:8675/index.php +87531;US-QuadNetATL;QuadNet-BM;107.191.121.105;42000;004;http://ysfr1.openquad.net/ +74247;US-RepeaterBook;DMR TG 31419;69.71.127.9;42000;002;http://matfield.heartlandtower.com:8675 +12224;US-YSF-NE;NEW-ENGLAND;54.144.216.63;42000;005;http://ysf.wizworks.net:41000/ +88051;US-YSF587NYS;YSF-QNetBridge;216.155.157.11;42000;001;http://ysfopenquad.ddns.net +54595;Virginia;Virginia YSF;45.33.118.112;42000;003;http://45.33.118.112/ysf/ +38635;Wires-X YO W;WiresX Romania;89.122.215.236;42001;004;http://wiresx.hamnet.ro +70375;YSF BRAZIL;C4FM BRAZIL PU;200.231.36.174;42000;007;http://ysf.pu2lrz.com +41577;YSF YO W;Fusion Romania;89.122.215.236;42000;009;http://ysf.hamnet.ro +24519;YSF-EA5 SPAIN;Zona EA5;84.127.124.188;42105;006;http://ea5gvk.duckdns.org:84/YSF +26626;YSF-TI;YSF Tango Indi;159.89.183.117;42000;000; +93029;YSF004 MI5 SW2;Crossconnect t;44.103.34.3;42000;003;http://ysf004.kb8zgl.net/YSFReflector +65576;YSF937;Guri, South Ko;1.240.221.206;42000;000;http://sojubox.iptime.org:8080/ysfreflector/ +31741;YSFColombiaLR;LCRA Fusion;120.146.216.45;42000;001;http://120.146.216.45/index.php From 0ad3f8712ac2231126364854e71e0d659762bf08 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 5 Mar 2018 20:00:29 +0000 Subject: [PATCH 20/20] Lots of Wires-X changes. --- YSFGateway/WiresX.cpp | 16 +++++--------- YSFGateway/WiresX.h | 42 ++++++++++++++++++------------------ YSFGateway/YSFGateway.cpp | 37 ++++++++++++++++++------------- YSFGateway/YSFGateway.h | 30 ++++++++++++++------------ YSFGateway/YSFGateway.ini | 1 + YSFGateway/YSFNetwork.cpp | 16 ++++++++++++-- YSFGateway/YSFNetwork.h | 4 +++- YSFGateway/YSFReflectors.cpp | 19 ++++++++++++++-- YSFGateway/YSFReflectors.h | 3 ++- 9 files changed, 101 insertions(+), 67 deletions(-) diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index dce4b25..db0aede 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -42,11 +42,11 @@ const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U}; const unsigned char NET_HEADER[] = "YSFD ALL "; -CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime) : +CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors) : m_callsign(callsign), m_node(), m_network(network), -m_reflectors(hostsFile, reloadTime), +m_reflectors(reflectors), m_reflector(NULL), m_id(), m_name(), @@ -159,10 +159,6 @@ void CWiresX::setYSF2DMR(const std::string& address, unsigned int port) bool CWiresX::start() { - bool ret = m_reflectors.load(); - if (!ret) - return false; - m_reflectors.reload(); return true; @@ -239,11 +235,9 @@ CYSFReflector* CWiresX::getReflector() const return m_reflector; } -CYSFReflector* CWiresX::getReflector(const std::string& id) +void CWiresX::setReflector(CYSFReflector* reflector) { - m_reflector = m_reflectors.find(id); - - return m_reflector; + m_reflector = reflector; } void CWiresX::processDX(const unsigned char* source) @@ -287,7 +281,7 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch std::string id = std::string((char*)data, 5U); - m_reflector = m_reflectors.find(id); + m_reflector = m_reflectors.findById(id); if (m_reflector == NULL) return WXS_NONE; diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index e1128cf..d979147 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -43,7 +43,7 @@ enum WXSI_STATUS { class CWiresX { public: - CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime); + CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors); ~CWiresX(); void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); @@ -55,7 +55,7 @@ public: WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); CYSFReflector* getReflector() const; - CYSFReflector* getReflector(const std::string& id); + void setReflector(CYSFReflector* reflector); void processConnect(CYSFReflector* reflector); void processDisconnect(const unsigned char* source = NULL); @@ -63,25 +63,25 @@ public: void clock(unsigned int ms); private: - std::string m_callsign; - std::string m_node; - CYSFNetwork* m_network; - CYSFReflectors m_reflectors; - CYSFReflector* m_reflector; - std::string m_id; - std::string m_name; - unsigned char* m_command; - unsigned int m_txFrequency; - unsigned int m_rxFrequency; - CTimer m_timer; - unsigned char m_seqNo; - unsigned char* m_header; - unsigned char* m_csd1; - unsigned char* m_csd2; - unsigned char* m_csd3; - WXSI_STATUS m_status; - unsigned int m_start; - std::string m_search; + std::string m_callsign; + std::string m_node; + CYSFNetwork* m_network; + CYSFReflectors& m_reflectors; + CYSFReflector* m_reflector; + std::string m_id; + std::string m_name; + unsigned char* m_command; + unsigned int m_txFrequency; + unsigned int m_rxFrequency; + CTimer m_timer; + unsigned char m_seqNo; + unsigned char* m_header; + unsigned char* m_csd1; + unsigned char* m_csd2; + unsigned char* m_csd3; + WXSI_STATUS m_status; + unsigned int m_start; + std::string m_search; WX_STATUS processConnect(const unsigned char* source, const unsigned char* data); void processDX(const unsigned char* source); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index d24527b..3cc0384 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -17,7 +17,6 @@ */ #include "YSFGateway.h" -#include "YSFReflectors.h" #include "UDPSocket.h" #include "StopWatch.h" #include "Version.h" @@ -80,6 +79,7 @@ m_callsign(), m_suffix(), m_conf(configFile), m_gps(NULL), +m_reflectors(NULL), m_wiresX(NULL), m_dtmf(), m_ysfNetwork(NULL), @@ -182,7 +182,7 @@ int CYSFGateway::run() unsigned int myPort = m_conf.getMyPort(); CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); - rptNetwork.setDestination(rptAddress, rptPort); + rptNetwork.setDestination("MMDVM", rptAddress, rptPort); ret = rptNetwork.open(); if (!ret) { @@ -224,6 +224,17 @@ int CYSFGateway::run() m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U); + std::string fileName = m_conf.getYSFNetworkHosts(); + unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); + + m_reflectors = new CYSFReflectors(fileName, reloadTime); + m_reflectors->load(); + m_reflectors->reload(); + + createWiresX(&rptNetwork); + + createGPS(); + m_startup = m_conf.getNetworkStartup(); bool revert = m_conf.getNetworkRevert(); @@ -234,10 +245,6 @@ int CYSFGateway::run() LogMessage("Starting YSFGateway-%s", VERSION); - createWiresX(&rptNetwork); - - createGPS(); - for (;;) { unsigned char buffer[200U]; @@ -441,10 +448,7 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork) { assert(rptNetwork != NULL); - std::string fileName = m_conf.getYSFNetworkHosts(); - unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); - - m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, fileName, reloadTime); + m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, *m_reflectors); std::string name = m_conf.getName(); @@ -485,7 +489,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u CYSFReflector* reflector = m_wiresX->getReflector(); LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); m_current = reflector->m_id; @@ -539,7 +543,7 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) switch (status) { case WXS_CONNECT_YSF: { std::string id = m_dtmf.getReflector(); - CYSFReflector* reflector = m_wiresX->getReflector(id); + CYSFReflector* reflector = m_reflectors->findById(id); if (reflector != NULL) { m_wiresX->processConnect(reflector); @@ -553,7 +557,7 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); m_current = id; @@ -576,6 +580,7 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) } if (m_linkType == LINK_YSF) { + m_wiresX->processDisconnect(); m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); } @@ -707,11 +712,13 @@ void CYSFGateway::startupLinking() m_lostTimer.stop(); m_linkType = LINK_NONE; - CYSFReflector* reflector = m_wiresX->getReflector(m_startup); + CYSFReflector* reflector = m_reflectors->findByName(m_startup); if (reflector != NULL) { LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port); + m_wiresX->setReflector(reflector); + + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); m_ysfNetwork->writePoll(3U); m_current = m_startup; diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index d401565..238277c 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -20,6 +20,7 @@ #define YSFGateway_H #include "YSFNetwork.h" +#include "YSFReflectors.h" #include "FCSNetwork.h" #include "WiresX.h" #include "Timer.h" @@ -44,20 +45,21 @@ public: int run(); private: - std::string m_callsign; - std::string m_suffix; - CConf m_conf; - CGPS* m_gps; - CWiresX* m_wiresX; - CDTMF m_dtmf; - CYSFNetwork* m_ysfNetwork; - CFCSNetwork* m_fcsNetwork; - LINK_TYPE m_linkType; - std::string m_current; - std::string m_startup; - bool m_exclude; - CTimer m_inactivityTimer; - CTimer m_lostTimer; + std::string m_callsign; + std::string m_suffix; + CConf m_conf; + CGPS* m_gps; + CYSFReflectors* m_reflectors; + CWiresX* m_wiresX; + CDTMF m_dtmf; + CYSFNetwork* m_ysfNetwork; + CFCSNetwork* m_fcsNetwork; + LINK_TYPE m_linkType; + std::string m_current; + std::string m_startup; + bool m_exclude; + CTimer m_inactivityTimer; + CTimer m_lostTimer; void startupLinking(); std::string calculateLocator(); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index b6c82f6..5ecddd3 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -36,6 +36,7 @@ Description=APRS Description [Network] # Startup=FCS00120 +# Startup=Alabama-Link InactivityTimeout=10 Revert=0 Debug=0 diff --git a/YSFGateway/YSFNetwork.cpp b/YSFGateway/YSFNetwork.cpp index 8a99c1d..b291be6 100644 --- a/YSFGateway/YSFNetwork.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -35,7 +35,9 @@ m_port(0U), m_poll(NULL), m_unlink(NULL), m_buffer(1000U, "YSF Network Buffer"), -m_pollTimer(1000U, 5U) +m_pollTimer(1000U, 5U), +m_name(), +m_linked(false) { m_poll = new unsigned char[14U]; ::memcpy(m_poll + 0U, "YSFP", 4U); @@ -89,16 +91,19 @@ bool CYSFNetwork::open() return m_socket.open(); } -void CYSFNetwork::setDestination(const in_addr& address, unsigned int port) +void CYSFNetwork::setDestination(const std::string& name, const in_addr& address, unsigned int port) { + m_name = name; m_address = address; m_port = port; + m_linked = false; } void CYSFNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; m_port = 0U; + m_linked = false; m_pollTimer.stop(); } @@ -136,6 +141,8 @@ void CYSFNetwork::writeUnlink(unsigned int count) for (unsigned int i = 0U; i < count; i++) m_socket.write(m_unlink, 14U, m_address, m_port); + + m_linked = false; } void CYSFNetwork::clock(unsigned int ms) @@ -158,6 +165,11 @@ void CYSFNetwork::clock(unsigned int ms) if (address.s_addr != m_address.s_addr || port != m_port) return; + if (::memcmp(buffer, "YSFP", 4U) == 0 && !m_linked) { + LogMessage("Linked to %s", m_name.c_str()); + m_linked = true; + } + if (m_debug) CUtils::dump(1U, "YSF Network Data Received", buffer, length); diff --git a/YSFGateway/YSFNetwork.h b/YSFGateway/YSFNetwork.h index eeb9708..30bfb39 100644 --- a/YSFGateway/YSFNetwork.h +++ b/YSFGateway/YSFNetwork.h @@ -35,7 +35,7 @@ public: bool open(); - void setDestination(const in_addr& address, unsigned int port); + void setDestination(const std::string& name, const in_addr& address, unsigned int port); void clearDestination(); void write(const unsigned char* data); @@ -58,6 +58,8 @@ private: unsigned char* m_unlink; CRingBuffer m_buffer; CTimer m_pollTimer; + std::string m_name; + bool m_linked; }; #endif diff --git a/YSFGateway/YSFReflectors.cpp b/YSFGateway/YSFReflectors.cpp index e72661a..134f674 100644 --- a/YSFGateway/YSFReflectors.cpp +++ b/YSFGateway/YSFReflectors.cpp @@ -163,9 +163,9 @@ bool CYSFReflectors::load() return true; } -CYSFReflector* CYSFReflectors::find(const std::string& id) +CYSFReflector* CYSFReflectors::findById(const std::string& id) { - for (std::vector::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) { + for (std::vector::const_iterator it = m_currReflectors.cbegin(); it != m_currReflectors.cend(); ++it) { if (id == (*it)->m_id) return *it; } @@ -175,6 +175,21 @@ CYSFReflector* CYSFReflectors::find(const std::string& id) return NULL; } +CYSFReflector* CYSFReflectors::findByName(const std::string& name) +{ + std::string fullName = name; + fullName.resize(16U, ' '); + + for (std::vector::const_iterator it = m_currReflectors.cbegin(); it != m_currReflectors.cend(); ++it) { + if (fullName == (*it)->m_name) + return *it; + } + + LogMessage("Trying to find non existent YSF reflector with a name of %s", name.c_str()); + + return NULL; +} + std::vector& CYSFReflectors::current() { return m_currReflectors; diff --git a/YSFGateway/YSFReflectors.h b/YSFGateway/YSFReflectors.h index bd5b7a7..cb5fed4 100644 --- a/YSFGateway/YSFReflectors.h +++ b/YSFGateway/YSFReflectors.h @@ -55,7 +55,8 @@ public: bool load(); - CYSFReflector* find(const std::string& id); + CYSFReflector* findById(const std::string& id); + CYSFReflector* findByName(const std::string& name); std::vector& current();