From 0e41513538732e5e0c670031266b874c3ef63c5f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 5 Jun 2020 09:27:03 +0100 Subject: [PATCH] Add debugging to APRS. --- YSFGateway/APRSWriter.cpp | 15 +++++++++++---- YSFGateway/APRSWriter.h | 3 ++- YSFGateway/Conf.cpp | 8 ++++++++ YSFGateway/Conf.h | 2 ++ YSFGateway/Version.h | 2 +- YSFGateway/YSFGateway.cpp | 3 ++- YSFGateway/YSFGateway.ini | 1 + 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/YSFGateway/APRSWriter.cpp b/YSFGateway/APRSWriter.cpp index 0e783c6..db8ca0c 100644 --- a/YSFGateway/APRSWriter.cpp +++ b/YSFGateway/APRSWriter.cpp @@ -25,9 +25,10 @@ #include #include -CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix) : +CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug) : m_idTimer(1000U), m_callsign(callsign), +m_debug(debug), m_txFrequency(0U), m_rxFrequency(0U), m_latitude(0.0F), @@ -178,6 +179,9 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned lon, (fLongitude < 0.0F) ? 'W' : 'E', symbol, type); + if (m_debug) + LogDebug("APRS ==> %s", output); + m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort); } @@ -273,14 +277,14 @@ void CAPRSWriter::sendIdFrameFixed() lon, (m_longitude < 0.0F) ? 'W' : 'E', float(m_height) * 3.28F, band, desc); + if (m_debug) + LogDebug("APRS ==> %s", output); + m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort); } void CAPRSWriter::sendIdFrameMobile() { - if (!m_gpsdEnabled) - return; - if (!::gps_waiting(&m_gpsdData, 0)) return; @@ -363,6 +367,9 @@ void CAPRSWriter::sendIdFrameMobile() ::sprintf(output + ::strlen(output), "%s %s\r\n", band, desc); + if (m_debug) + LogDebug("APRS ==> %s", output); + m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort); } diff --git a/YSFGateway/APRSWriter.h b/YSFGateway/APRSWriter.h index 9a0d17d..f0e10ad 100644 --- a/YSFGateway/APRSWriter.h +++ b/YSFGateway/APRSWriter.h @@ -40,7 +40,7 @@ class CAPRSWriter { public: - CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix); + CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug); ~CAPRSWriter(); bool open(); @@ -60,6 +60,7 @@ public: private: CTimer m_idTimer; std::string m_callsign; + bool m_debug; unsigned int m_txFrequency; unsigned int m_rxFrequency; float m_latitude; diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index d87704d..eb5b2b4 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -50,6 +50,7 @@ m_myAddress(), m_myPort(0U), m_wiresXMakeUpper(true), m_wiresXCommandPassthrough(false), +m_debug(false), m_daemon(false), m_rxFrequency(0U), m_txFrequency(0U), @@ -169,6 +170,8 @@ bool CConf::read() m_wiresXMakeUpper = ::atoi(value) == 1; else if (::strcmp(key, "WiresXCommandPassthrough") == 0) m_wiresXCommandPassthrough = ::atoi(value) == 1; + else if (::strcmp(key, "Debug") == 0) + m_debug = ::atoi(value) == 1; else if (::strcmp(key, "Daemon") == 0) m_daemon = ::atoi(value) == 1; } else if (section == SECTION_INFO) { @@ -314,6 +317,11 @@ bool CConf::getWiresXCommandPassthrough() const return m_wiresXCommandPassthrough; } +bool CConf::getDebug() const +{ + return m_debug; +} + bool CConf::getDaemon() const { return m_daemon; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index ea2a611..7f07a9c 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -39,6 +39,7 @@ public: unsigned int getMyPort() const; bool getWiresXMakeUpper() const; bool getWiresXCommandPassthrough() const; + bool getDebug() const; bool getDaemon() const; // The Info section @@ -109,6 +110,7 @@ private: unsigned int m_myPort; bool m_wiresXMakeUpper; bool m_wiresXCommandPassthrough; + bool m_debug; bool m_daemon; unsigned int m_rxFrequency; diff --git a/YSFGateway/Version.h b/YSFGateway/Version.h index 3f80005..eca752d 100644 --- a/YSFGateway/Version.h +++ b/YSFGateway/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200604"; +const char* VERSION = "20200605"; #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 2847638..55fefb1 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -457,8 +457,9 @@ void CYSFGateway::createGPS() std::string address = m_conf.getAPRSAddress(); unsigned int port = m_conf.getAPRSPort(); std::string suffix = m_conf.getAPRSSuffix(); + bool debug = m_conf.getDebug(); - m_writer = new CAPRSWriter(m_callsign, m_suffix, address, port, suffix); + m_writer = new CAPRSWriter(m_callsign, m_suffix, address, port, suffix, debug); unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 21e6815..104909b 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -9,6 +9,7 @@ LocalAddress=127.0.0.1 LocalPort=4200 WiresXMakeUpper=1 WiresXCommandPassthrough=0 +Debug=0 Daemon=0 [Info]