diff --git a/NXDNGateway/APRSWriter.cpp b/NXDNGateway/APRSWriter.cpp index 4af0f7d..231b594 100644 --- a/NXDNGateway/APRSWriter.cpp +++ b/NXDNGateway/APRSWriter.cpp @@ -24,10 +24,10 @@ #include #include -CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& address, unsigned int port) : -m_enabled(false), +CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& address, unsigned int port, bool debug) : m_idTimer(1000U), m_callsign(callsign), +m_debug(debug), m_txFrequency(0U), m_rxFrequency(0U), m_latitude(0.0F), @@ -123,6 +123,9 @@ void CAPRSWriter::write(const char* data) { assert(data != NULL); + if (m_debug) + LogDebug("APRS ==> %s", data); + m_aprsSocket.write((unsigned char*)data, (unsigned int)::strlen(data), m_aprsAddress, m_aprsPort); } @@ -218,14 +221,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); + write(output); } void CAPRSWriter::sendIdFrameMobile() { - if (!m_gpsdEnabled) - return; - if (!::gps_waiting(&m_gpsdData, 0)) return; @@ -308,6 +311,9 @@ void CAPRSWriter::sendIdFrameMobile() ::sprintf(output + ::strlen(output), "%s %s\r\n", band, desc); + if (m_debug) + LogDebug("APRS ==> %s", output); + write(output); } diff --git a/NXDNGateway/APRSWriter.h b/NXDNGateway/APRSWriter.h index 21f322f..461d945 100644 --- a/NXDNGateway/APRSWriter.h +++ b/NXDNGateway/APRSWriter.h @@ -40,7 +40,7 @@ class CAPRSWriter { public: - CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& address, unsigned int port); + CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& address, unsigned int port, bool debug); ~CAPRSWriter(); bool open(); @@ -58,9 +58,9 @@ public: void close(); private: - bool m_enabled; CTimer m_idTimer; std::string m_callsign; + bool m_debug; unsigned int m_txFrequency; unsigned int m_rxFrequency; float m_latitude; diff --git a/NXDNGateway/Conf.cpp b/NXDNGateway/Conf.cpp index d1969b0..df80dd1 100644 --- a/NXDNGateway/Conf.cpp +++ b/NXDNGateway/Conf.cpp @@ -47,7 +47,7 @@ m_rptProtocol("Icom"), m_rptAddress(), m_rptPort(0U), m_myPort(0U), -m_rptDebug(false), +m_debug(false), m_daemon(false), m_rxFrequency(0U), m_txFrequency(0U), @@ -157,7 +157,7 @@ bool CConf::read() else if (::strcmp(key, "LocalPort") == 0) m_myPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) - m_rptDebug = ::atoi(value) == 1; + m_debug = ::atoi(value) == 1; else if (::strcmp(key, "Daemon") == 0) m_daemon = ::atoi(value) == 1; } else if (section == SECTION_INFO) { @@ -278,9 +278,9 @@ unsigned int CConf::getMyPort() const return m_myPort; } -bool CConf::getRptDebug() const +bool CConf::getDebug() const { - return m_rptDebug; + return m_debug; } bool CConf::getDaemon() const diff --git a/NXDNGateway/Conf.h b/NXDNGateway/Conf.h index 32794cf..5700b40 100644 --- a/NXDNGateway/Conf.h +++ b/NXDNGateway/Conf.h @@ -37,7 +37,7 @@ public: std::string getRptAddress() const; unsigned int getRptPort() const; unsigned int getMyPort() const; - bool getRptDebug() const; + bool getDebug() const; bool getDaemon() const; // The Info section @@ -100,7 +100,7 @@ private: std::string m_rptAddress; unsigned int m_rptPort; unsigned int m_myPort; - bool m_rptDebug; + bool m_debug; bool m_daemon; unsigned int m_rxFrequency; diff --git a/NXDNGateway/NXDNGateway.cpp b/NXDNGateway/NXDNGateway.cpp index 8f4df31..5277b07 100644 --- a/NXDNGateway/NXDNGateway.cpp +++ b/NXDNGateway/NXDNGateway.cpp @@ -184,9 +184,9 @@ void CNXDNGateway::run() std::string protocol = m_conf.getRptProtocol(); if (protocol == "Kenwood") - localNetwork = new CKenwoodNetwork(m_conf.getMyPort(), m_conf.getRptAddress(), m_conf.getRptPort(), m_conf.getRptDebug()); + localNetwork = new CKenwoodNetwork(m_conf.getMyPort(), m_conf.getRptAddress(), m_conf.getRptPort(), m_conf.getDebug()); else - localNetwork = new CIcomNetwork(m_conf.getMyPort(), m_conf.getRptAddress(), m_conf.getRptPort(), m_conf.getRptDebug()); + localNetwork = new CIcomNetwork(m_conf.getMyPort(), m_conf.getRptAddress(), m_conf.getRptPort(), m_conf.getDebug()); ret = localNetwork->open(); if (!ret) { @@ -594,8 +594,9 @@ void CNXDNGateway::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(callsign, rptSuffix, address, port); + m_writer = new CAPRSWriter(callsign, rptSuffix, address, port, debug); unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/NXDNGateway/Version.h b/NXDNGateway/Version.h index a17701b..b2493a9 100644 --- a/NXDNGateway/Version.h +++ b/NXDNGateway/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200604"; +const char* VERSION = "20200605"; #endif