From d05a5af88408323b3e41ea2fc8dd9d8c4da16f24 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 07:01:49 +0100 Subject: [PATCH 01/17] Hide intermediate files --- .vscode/settings.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 42e5956..fd4dede 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -75,6 +75,16 @@ "iostream": "cpp", "fstream": "cpp" }, + "files.exclude": { + "**/.DS_Store": true, + "**/.git": true, + "**/.hg": true, + "**/.svn": true, + "**/*.d": true, + "**/*.o": true, + "**/CVS": true, + "**/Thumbs.db": true + }, "editor.tokenColorCustomizations": { "textMateRules": [ { From 39057bb6e342ddd90a1570b67f459fb6c2d33982 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 07:07:34 +0100 Subject: [PATCH 02/17] #29 comment typo --- Common/NMEASentenceCollector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/NMEASentenceCollector.cpp b/Common/NMEASentenceCollector.cpp index 9caa630..87c5817 100644 --- a/Common/NMEASentenceCollector.cpp +++ b/Common/NMEASentenceCollector.cpp @@ -58,7 +58,7 @@ unsigned char CNMEASentenceCollector::calcXOR(const std::string& nmea) unsigned char res = 0U; if(!nmea.empty()) { - unsigned int i = nmea[0] == '$' ? 1U : 0U; //skip $ it it is there + unsigned int i = nmea[0] == '$' ? 1U : 0U; //skip $ if it is there while(i < nmea.length()) { if(nmea[i] != '*') { From 137727deed4b91b9451e2ff64848bbc71e0893f3 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 07:48:45 +0100 Subject: [PATCH 03/17] #29 change dump log target to debug --- BaseCommon/Utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseCommon/Utils.cpp b/BaseCommon/Utils.cpp index ebb1c57..c5d6746 100644 --- a/BaseCommon/Utils.cpp +++ b/BaseCommon/Utils.cpp @@ -70,7 +70,7 @@ void CUtils::dump(const char* title, const bool* data, unsigned int length) output += "*'"; - CLog::logInfo("%04X: %s\n", offset / 8U, output.c_str()); + CLog::logDebug("%04X: %s\n", offset / 8U, output.c_str()); offset += 128U; } @@ -115,7 +115,7 @@ void CUtils::dumpRev(const char* title, const bool* data, unsigned int length) output += "*"; - CLog::logInfo("%04X: %s\n", offset / 8U, output.c_str()); + CLog::logDebug("%04X: %s\n", offset / 8U, output.c_str()); offset += 128U; } @@ -157,7 +157,7 @@ void CUtils::dump(const char* title, const unsigned char* data, unsigned int len output += "*"; - CLog::logInfo("%04X: %s\n", offset, output.c_str()); + CLog::logDebug("%04X: %s\n", offset, output.c_str()); offset += 16U; From 8bc974e8272e065a64dee94c3177843213ad5168 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 07:49:44 +0100 Subject: [PATCH 04/17] #29 clarify log --- Common/APRSHandlerThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/APRSHandlerThread.cpp b/Common/APRSHandlerThread.cpp index e3098c6..3eec467 100644 --- a/Common/APRSHandlerThread.cpp +++ b/Common/APRSHandlerThread.cpp @@ -151,7 +151,7 @@ void* CAPRSHandlerThread::Entry() if(!m_queue.empty()){ auto frameStr = m_queue.getData(); - CLog::logInfo("APRS ==> %s", frameStr.c_str()); + CLog::logInfo("APRS Frame sent to IS ==> %s", frameStr.c_str()); bool ret = m_socket.writeLine(frameStr); if (!ret) { From e0892325db82e956fafa64aa077337658db44f15 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 08:34:40 +0100 Subject: [PATCH 05/17] update settings --- .vscode/settings.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fd4dede..df80dfe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -73,7 +73,15 @@ "typeindex": "cpp", "variant": "cpp", "iostream": "cpp", - "fstream": "cpp" + "fstream": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "strstream": "cpp", + "codecvt": "cpp", + "numeric": "cpp", + "regex": "cpp", + "cfenv": "cpp", + "cinttypes": "cpp" }, "files.exclude": { "**/.DS_Store": true, From 6d889c93721f3b1d90cf2b00982639e57906fd6a Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 08:34:58 +0100 Subject: [PATCH 06/17] #29 ad logging of DPRS --- Common/APRSCollector.cpp | 12 ++++++++---- Common/APRSCollector.h | 5 +++-- Common/APRSHandler.cpp | 13 +++++++------ Common/NMEASentenceCollector.cpp | 4 ++-- Common/SlowDataCollector.cpp | 20 +++++++++++++++----- Common/SlowDataCollector.h | 15 ++++++++++----- Common/SlowDataCollectorThrottle.cpp | 19 +++++++++++++++---- Common/SlowDataCollectorThrottle.h | 6 ++++-- 8 files changed, 64 insertions(+), 30 deletions(-) diff --git a/Common/APRSCollector.cpp b/Common/APRSCollector.cpp index afba4d0..83bd8af 100644 --- a/Common/APRSCollector.cpp +++ b/Common/APRSCollector.cpp @@ -51,10 +51,14 @@ CAPRSCollector::~CAPRSCollector() m_collectors.clear(); } -void CAPRSCollector::writeHeader(const std::string& callsign) +void CAPRSCollector::writeHeader(const CHeaderData& header) { + std::string mycall1 = header.getMyCall1(); + std::string mycall2 = header.getMyCall2(); + for(auto collector : m_collectors) { - collector->setMyCall(callsign); + collector->setMyCall1(mycall1); + collector->setMyCall2(mycall2); } } @@ -95,12 +99,12 @@ unsigned int CAPRSCollector::getData(unsigned char dataType, unsigned char* data return 0U; } -void CAPRSCollector::getData(std::function dataHandler) +void CAPRSCollector::getData(std::function dataHandler) { for(auto collector : m_collectors) { std::string data; if(collector->getData(data)) { - dataHandler(data); + dataHandler(data, collector->getMyCall1().append("/").append(collector->getMyCall2())); collector->reset(); } } diff --git a/Common/APRSCollector.h b/Common/APRSCollector.h index 2f955bf..8e9ae3a 100644 --- a/Common/APRSCollector.h +++ b/Common/APRSCollector.h @@ -24,6 +24,7 @@ #include #include "SlowDataCollector.h" +#include "HeaderData.h" #include "Defs.h" enum APRS_STATE { @@ -39,7 +40,7 @@ public: CAPRSCollector(); ~CAPRSCollector(); - void writeHeader(const std::string& callsign); + void writeHeader(const CHeaderData& callsign); bool writeData(const unsigned char* data); @@ -49,7 +50,7 @@ public: unsigned int getData(unsigned char dataType, unsigned char* data, unsigned int length); - void getData(std::function dataHandler); + void getData(std::function dataHandler); void clock(unsigned int ms); diff --git a/Common/APRSHandler.cpp b/Common/APRSHandler.cpp index c81a745..919bb13 100644 --- a/Common/APRSHandler.cpp +++ b/Common/APRSHandler.cpp @@ -22,7 +22,6 @@ #include #include #include - #include "StringUtils.h" #include "Log.h" #include "APRSHandler.h" @@ -89,7 +88,7 @@ void CAPRSHandler::writeHeader(const std::string& callsign, const CHeaderData& h CAPRSCollector* collector = entry->getCollector(); - collector->writeHeader(header.getMyCall1()); + collector->writeHeader(header); } void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data) @@ -122,17 +121,17 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data) return; } - collector->getData([=](const std::string& text) + collector->getData([=](const std::string& rawFrame, const std::string& dstarCall) { CAPRSFrame frame; - if(!CAPRSParser::parseFrame(text, frame)) { - CLog::logWarning("Failed to parse DPRS Frame : %s", text.c_str()); + if(!CAPRSParser::parseFrame(rawFrame, frame)) { + CLog::logWarning("Failed to parse DPRS Frame : %s", rawFrame.c_str()); return; } // If we already have a q-construct, don't send it on if(std::any_of(frame.getPath().begin(), frame.getPath().end(), [] (std::string s) { return !s.empty() && s[0] == 'q'; })) { - CLog::logWarning("DPRS Frame already has q construct, not forwarding to APRS-IS: %s", text.c_str()); + CLog::logWarning("DPRS Frame already has q construct, not forwarding to APRS-IS: %s", rawFrame.c_str()); return; } @@ -142,6 +141,8 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data) std::string output ; CAPRSFormater::frameToString(output, frame); + CLog::logInfo("DPRS\t%s\t%s\t%s", dstarCall.c_str(), frame.getSource().c_str(), rawFrame.c_str()); + m_thread->write(frame); }); } diff --git a/Common/NMEASentenceCollector.cpp b/Common/NMEASentenceCollector.cpp index 87c5817..5136a61 100644 --- a/Common/NMEASentenceCollector.cpp +++ b/Common/NMEASentenceCollector.cpp @@ -98,14 +98,14 @@ unsigned int CNMEASentenceCollector::getDataInt(unsigned char * data, unsigned i bool CNMEASentenceCollector::getDataInt(std::string& data) { - if(getMyCall().empty() || getSentence().empty()) + if(getMyCall1().empty() || getSentence().empty()) return false; data.clear(); auto nmea = getSentence(); fixUpNMEATimeStamp(nmea); - std::string fromCall = getMyCall(); + std::string fromCall = getMyCall1(); CAPRSUtils::dstarCallsignToAPRS(fromCall); std::string aprsFrame(fromCall); aprsFrame.append("-5>GPS30,DSTAR*:") diff --git a/Common/SlowDataCollector.cpp b/Common/SlowDataCollector.cpp index b9caad0..55f38e7 100644 --- a/Common/SlowDataCollector.cpp +++ b/Common/SlowDataCollector.cpp @@ -27,7 +27,7 @@ const unsigned int SLOW_DATA_BLOCK_LENGTH = 6U; CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) : m_slowDataType(slowDataType), -m_myCall(), +m_myCall1(), m_state(SS_FIRST) { m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH]; @@ -39,14 +39,24 @@ CSlowDataCollector::~CSlowDataCollector() delete[] m_buffer; } -std::string CSlowDataCollector::getMyCall() const +std::string CSlowDataCollector::getMyCall1() const { - return m_myCall; + return m_myCall1; } -void CSlowDataCollector::setMyCall(const std::string& myCall) +void CSlowDataCollector::setMyCall1(const std::string& myCall) { - m_myCall = myCall; + m_myCall1 = myCall; +} + +std::string CSlowDataCollector::getMyCall2() const +{ + return m_myCall2; +} + +void CSlowDataCollector::setMyCall2(const std::string& myCall) +{ + m_myCall2 = myCall; } bool CSlowDataCollector::writeData(const unsigned char* data) diff --git a/Common/SlowDataCollector.h b/Common/SlowDataCollector.h index f2389f9..1f6c803 100644 --- a/Common/SlowDataCollector.h +++ b/Common/SlowDataCollector.h @@ -29,8 +29,10 @@ class ISlowDataCollector public: virtual ~ISlowDataCollector() { } ; - virtual std::string getMyCall() const = 0; - virtual void setMyCall(const std::string& mycall) = 0; + virtual std::string getMyCall1() const = 0; + virtual void setMyCall1(const std::string& mycall) = 0; + virtual std::string getMyCall2() const = 0; + virtual void setMyCall2(const std::string& mycall) = 0; virtual bool writeData(const unsigned char* data) = 0; virtual void sync() = 0; virtual unsigned int getData(unsigned char* data, unsigned int length) = 0; @@ -46,8 +48,10 @@ public: CSlowDataCollector(unsigned char slowDataType); virtual ~CSlowDataCollector(); - std::string getMyCall() const; - void setMyCall(const std::string& mycall); + std::string getMyCall1() const; + void setMyCall1(const std::string& mycall); + std::string getMyCall2() const; + void setMyCall2(const std::string& mycall); bool writeData(const unsigned char* data); void sync(); unsigned int getData(unsigned char* data, unsigned int length); @@ -64,7 +68,8 @@ protected: private: unsigned char m_slowDataType; - std::string m_myCall; + std::string m_myCall1; + std::string m_myCall2; SLOWDATA_STATE m_state; unsigned char * m_buffer; }; \ No newline at end of file diff --git a/Common/SlowDataCollectorThrottle.cpp b/Common/SlowDataCollectorThrottle.cpp index 8d97fe1..37e0f23 100644 --- a/Common/SlowDataCollectorThrottle.cpp +++ b/Common/SlowDataCollectorThrottle.cpp @@ -33,16 +33,27 @@ CSlowDataCollectorThrottle::~CSlowDataCollectorThrottle() delete m_collector; } -std::string CSlowDataCollectorThrottle::getMyCall() const +std::string CSlowDataCollectorThrottle::getMyCall1() const { - return m_collector->getMyCall(); + return m_collector->getMyCall1(); } -void CSlowDataCollectorThrottle::setMyCall(const std::string& mycall) +void CSlowDataCollectorThrottle::setMyCall1(const std::string& mycall) { m_isFirst = true; - m_collector->setMyCall(mycall); + m_collector->setMyCall1(mycall); } +std::string CSlowDataCollectorThrottle::getMyCall2() const +{ + return m_collector->getMyCall2(); +} + +void CSlowDataCollectorThrottle::setMyCall2(const std::string& mycall) +{ + m_isFirst = true; + m_collector->setMyCall2(mycall); +} + bool CSlowDataCollectorThrottle::writeData(const unsigned char* data) { m_isComplete = false; diff --git a/Common/SlowDataCollectorThrottle.h b/Common/SlowDataCollectorThrottle.h index f7fbd23..55ca7b4 100644 --- a/Common/SlowDataCollectorThrottle.h +++ b/Common/SlowDataCollectorThrottle.h @@ -28,8 +28,10 @@ class CSlowDataCollectorThrottle : public ISlowDataCollector public: CSlowDataCollectorThrottle(ISlowDataCollector* collector, unsigned int timeout); ~CSlowDataCollectorThrottle(); - std::string getMyCall() const; - void setMyCall(const std::string& mycall); + std::string getMyCall1() const; + void setMyCall1(const std::string& mycall); + std::string getMyCall2() const; + void setMyCall2(const std::string& mycall); bool writeData(const unsigned char* data); void sync(); unsigned int getData(unsigned char* data, unsigned int length); From f90d5655ceeec1ad3c9b3218debb17bcd512789b Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 12:26:46 +0100 Subject: [PATCH 07/17] #29 clarify log --- Common/APRSHandlerThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/APRSHandlerThread.cpp b/Common/APRSHandlerThread.cpp index 3eec467..494e474 100644 --- a/Common/APRSHandlerThread.cpp +++ b/Common/APRSHandlerThread.cpp @@ -176,7 +176,7 @@ void* CAPRSHandlerThread::Entry() } else if(line.length() > 0 && line[0] != '#') { m_keepAliveTimer.start(); - CLog::logDebug("APRS <== %s", line.c_str()); + CLog::logDebug("APRS Frame received from IS <== %s", line.c_str()); CAPRSFrame readFrame; if(CAPRSParser::parseFrame(line, readFrame)) { for(auto cb : m_APRSReadCallbacks) { From d86b36c2f0699dceb46f3a9eb77874dbde630a2b Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 19:27:04 +0100 Subject: [PATCH 08/17] #29 refactor APRS Handling, prepare for more testable code --- Common/APRSFixedIdFrameProvider.cpp | 10 ++++----- Common/APRSFixedIdFrameProvider.h | 4 ++-- Common/APRSGPSDIdFrameProvider.cpp | 14 ++++++------ Common/APRSGPSDIdFrameProvider.h | 4 ++-- Common/APRSHandler.cpp | 23 +++++-------------- Common/APRSHandler.h | 9 +++----- Common/APRSHandlerThread.h | 4 ++-- Common/APRSIdFrameProvider.cpp | 14 +++++++++--- Common/APRSIdFrameProvider.h | 8 ++++--- Common/IAPRSHandlerThread.h | 35 +++++++++++++++++++++++++++++ DStarGateway/DStarGatewayApp.cpp | 12 +++++----- DStarGateway/DStarGatewayThread.cpp | 2 +- 12 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 Common/IAPRSHandlerThread.h diff --git a/Common/APRSFixedIdFrameProvider.cpp b/Common/APRSFixedIdFrameProvider.cpp index 9434175..b09ae9e 100644 --- a/Common/APRSFixedIdFrameProvider.cpp +++ b/Common/APRSFixedIdFrameProvider.cpp @@ -23,13 +23,13 @@ #include "APRSFixedIdFrameProvider.h" #include "StringUtils.h" -CAPRSFixedIdFrameProvider::CAPRSFixedIdFrameProvider() : -CAPRSIdFrameProvider(20U) // Initial timeout of 20 seconds +CAPRSFixedIdFrameProvider::CAPRSFixedIdFrameProvider(const std::string& gateway) : +CAPRSIdFrameProvider(gateway, 20U) // Initial timeout of 20 seconds { } -bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * entry, std::vector& frames) +bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std::vector& frames) { if (entry == nullptr) return false; @@ -114,9 +114,9 @@ bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, c lon.c_str(), (entry->getLongitude() < 0.0F) ? 'W' : 'E', entry->getRange() * 0.6214, entry->getAGL() * 3.28, band.c_str(), desc.c_str()); - CAPRSFrame * frame = new CAPRSFrame(gateway + "-S", + CAPRSFrame * frame = new CAPRSFrame(m_gateway + "-S", "APD5T1", - { "TCPIP*", "qAC" , gateway + "-GS" }, + { "TCPIP*", "qAC" , m_gateway + "-GS" }, body, APFT_OBJECT); frames.push_back(frame); diff --git a/Common/APRSFixedIdFrameProvider.h b/Common/APRSFixedIdFrameProvider.h index 8fa7032..c073a37 100644 --- a/Common/APRSFixedIdFrameProvider.h +++ b/Common/APRSFixedIdFrameProvider.h @@ -23,8 +23,8 @@ class CAPRSFixedIdFrameProvider : public CAPRSIdFrameProvider { public: - CAPRSFixedIdFrameProvider(); + CAPRSFixedIdFrameProvider(const std::string& gateway); protected: - virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector& frames); + virtual bool buildAPRSFramesInt(const CAPRSEntry * aprsEntry, std::vector& frames); }; diff --git a/Common/APRSGPSDIdFrameProvider.cpp b/Common/APRSGPSDIdFrameProvider.cpp index f67f634..7f621be 100644 --- a/Common/APRSGPSDIdFrameProvider.cpp +++ b/Common/APRSGPSDIdFrameProvider.cpp @@ -24,8 +24,8 @@ #include "StringUtils.h" #include "Log.h" -CAPRSGPSDIdFrameProvider::CAPRSGPSDIdFrameProvider(std::string address, std::string port) : -CAPRSIdFrameProvider(20U), +CAPRSGPSDIdFrameProvider::CAPRSGPSDIdFrameProvider(const std::string& gateway, const std::string& address, const std::string& port) : +CAPRSIdFrameProvider(gateway, 20U), m_gpsdAddress(address), m_gpsdPort(port), m_gpsdData(), @@ -56,7 +56,7 @@ void CAPRSGPSDIdFrameProvider::close() } } -bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * entry, std::vector& frames) +bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std::vector& frames) { if(!m_hasConnection) { this->start(); @@ -182,9 +182,9 @@ bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, co body.append(CStringUtils::string_format("RNG%04.0lf %s %s\r\n", entry->getRange() * 0.6214, band.c_str(), desc.c_str())); - CAPRSFrame * frame = new CAPRSFrame(gateway + "-S", + CAPRSFrame * frame = new CAPRSFrame(m_gateway + "-S", "APD5T1", - { "TCPIP*", "qAC" , gateway + "-GS" }, + { "TCPIP*", "qAC" , m_gateway + "-GS" }, body, APFT_OBJECT); @@ -201,9 +201,9 @@ bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, co lat.c_str(), (rawLatitude < 0.0) ? 'S' : 'N', lon.c_str(), (rawLongitude < 0.0) ? 'W' : 'E'); - frame = new CAPRSFrame(gateway, + frame = new CAPRSFrame(m_gateway, "APD5T2", - { "TCPIP*", "qAC" , gateway + "-GS" }, + { "TCPIP*", "qAC" , m_gateway + "-GS" }, body, APFT_POSITION); frames.push_back(frame); diff --git a/Common/APRSGPSDIdFrameProvider.h b/Common/APRSGPSDIdFrameProvider.h index e982f9b..eca659e 100644 --- a/Common/APRSGPSDIdFrameProvider.h +++ b/Common/APRSGPSDIdFrameProvider.h @@ -29,13 +29,13 @@ class CAPRSGPSDIdFrameProvider : public CAPRSIdFrameProvider { public: - CAPRSGPSDIdFrameProvider(std::string address, std::string port); + CAPRSGPSDIdFrameProvider(const std::string& gateway, const std::string& address, const std::string& port); virtual void start(); virtual void close(); protected: - virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector& frames); + virtual bool buildAPRSFramesInt(const CAPRSEntry * aprsEntry, std::vector& frames); private: std::string m_gpsdAddress; diff --git a/Common/APRSHandler.cpp b/Common/APRSHandler.cpp index 919bb13..50dd130 100644 --- a/Common/APRSHandler.cpp +++ b/Common/APRSHandler.cpp @@ -18,10 +18,10 @@ */ #include -#include #include #include #include + #include "StringUtils.h" #include "Log.h" #include "APRSHandler.h" @@ -33,24 +33,12 @@ #include "APRSFormater.h" #include "APRSUtils.h" -CAPRSHandler::CAPRSHandler(const std::string& hostname, unsigned int port, const std::string& gateway, const std::string& password, const std::string& address) : -m_thread(NULL), -m_gateway(), -m_address(), -m_port(0U), +CAPRSHandler::CAPRSHandler(IAPRSHandlerThread* thread) : +m_thread(thread), m_array(), m_idFrameProvider(nullptr) { - assert(!hostname.empty()); - assert(port > 0U); - assert(!gateway.empty()); - assert(!password.empty()); - - m_thread = new CAPRSHandlerThread(gateway, password, address, hostname, port); - - m_gateway = gateway; - m_gateway = m_gateway.substr(0, LONG_CALLSIGN_LENGTH - 1U); - boost::trim(m_gateway); + assert(thread != nullptr); } CAPRSHandler::~CAPRSHandler() @@ -60,6 +48,7 @@ CAPRSHandler::~CAPRSHandler() } m_array.clear(); + delete m_thread; } void CAPRSHandler::setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) @@ -210,7 +199,7 @@ void CAPRSHandler::sendIdFrames() { for(auto entry : m_array) { std::vector frames; - if(m_idFrameProvider->buildAPRSFrames(m_gateway, entry.second, frames)) { + if(m_idFrameProvider->buildAPRSFrames(entry.second, frames)) { for(auto frame : frames) { m_thread->write(*frame); delete frame; diff --git a/Common/APRSHandler.h b/Common/APRSHandler.h index 743ad37..0958d0a 100644 --- a/Common/APRSHandler.h +++ b/Common/APRSHandler.h @@ -26,7 +26,6 @@ #include "APRSEntry.h" -#include "APRSHandlerThread.h" #include "UDPReaderWriter.h" #include "APRSCollector.h" #include "DStarDefines.h" @@ -34,10 +33,11 @@ #include "AMBEData.h" #include "Timer.h" #include "APRSIdFrameProvider.h" +#include "IAPRSHandlerThread.h" class CAPRSHandler { public: - CAPRSHandler(const std::string& hostname, unsigned int port, const std::string& gateway, const std::string& password, const std::string& address); + CAPRSHandler(IAPRSHandlerThread * thread); ~CAPRSHandler(); bool open(); @@ -61,10 +61,7 @@ public: void addReadAPRSCallback(IReadAPRSFrameCallback* cb); private: - CAPRSHandlerThread* m_thread; - std::string m_gateway; - in_addr m_address; - unsigned int m_port; + IAPRSHandlerThread* m_thread; std::unordered_map m_array; CAPRSIdFrameProvider * m_idFrameProvider; diff --git a/Common/APRSHandlerThread.h b/Common/APRSHandlerThread.h index 01410de..fdeef68 100644 --- a/Common/APRSHandlerThread.h +++ b/Common/APRSHandlerThread.h @@ -25,11 +25,11 @@ #include "RingBuffer.h" #include "Timer.h" #include "Thread.h" -#include "ReadAPRSFrameCallback.h" +#include "IAPRSHandlerThread.h" #include "APRSFrame.h" -class CAPRSHandlerThread : public CThread { +class CAPRSHandlerThread : public CThread, IAPRSHandlerThread { public: CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port); CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter); diff --git a/Common/APRSIdFrameProvider.cpp b/Common/APRSIdFrameProvider.cpp index 3637f9d..fc8b6e0 100644 --- a/Common/APRSIdFrameProvider.cpp +++ b/Common/APRSIdFrameProvider.cpp @@ -17,13 +17,21 @@ */ #include +#include #include "APRSIdFrameProvider.h" -CAPRSIdFrameProvider::CAPRSIdFrameProvider(unsigned int timeout) : +CAPRSIdFrameProvider::CAPRSIdFrameProvider(const std::string& gateway, unsigned int timeout) : +m_gateway(), m_timer(1000U) { + assert(!gateway.empty()); + m_timer.start(timeout); + + m_gateway = gateway; + m_gateway = m_gateway.substr(0, LONG_CALLSIGN_LENGTH - 1U); + boost::trim(m_gateway); } CAPRSIdFrameProvider::~CAPRSIdFrameProvider() @@ -31,11 +39,11 @@ CAPRSIdFrameProvider::~CAPRSIdFrameProvider() } -bool CAPRSIdFrameProvider::buildAPRSFrames(const std::string& gateway, const CAPRSEntry * entry, std::vector & frames) +bool CAPRSIdFrameProvider::buildAPRSFrames(const CAPRSEntry * entry, std::vector & frames) { assert(entry != nullptr); - return buildAPRSFramesInt(gateway, entry, frames); + return buildAPRSFramesInt(entry, frames); } bool CAPRSIdFrameProvider::wantsToSend() diff --git a/Common/APRSIdFrameProvider.h b/Common/APRSIdFrameProvider.h index 48917ee..f123118 100644 --- a/Common/APRSIdFrameProvider.h +++ b/Common/APRSIdFrameProvider.h @@ -27,23 +27,25 @@ class CAPRSIdFrameProvider { public: - CAPRSIdFrameProvider(unsigned int timeOut); + CAPRSIdFrameProvider(const std::string& gateway, unsigned int timeOut); virtual ~CAPRSIdFrameProvider(); - bool buildAPRSFrames(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector& frames); + bool buildAPRSFrames(const CAPRSEntry * aprsEntry, std::vector& frames); void clock(unsigned int ms) { m_timer.clock(ms); } bool wantsToSend(); virtual void start() { }; virtual void close() { }; protected: - virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector& frames) = 0; + virtual bool buildAPRSFramesInt(const CAPRSEntry * aprsEntry, std::vector& frames) = 0; void setTimeout(unsigned int timeout) { m_timer.start(timeout); } +protected: + std::string m_gateway; private: CTimer m_timer; }; \ No newline at end of file diff --git a/Common/IAPRSHandlerThread.h b/Common/IAPRSHandlerThread.h new file mode 100644 index 0000000..991f8f5 --- /dev/null +++ b/Common/IAPRSHandlerThread.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021, 2022 by Geoffrey Merck F4FXL / KC3FRA + * + * 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. + */ + +#pragma once + +#include "APRSFrame.h" +#include "ReadAPRSFrameCallback.h" + +class IAPRSHandlerThread +{ +public: + virtual ~IAPRSHandlerThread() { } ; + + virtual bool start() = 0; + virtual bool isConnected() const = 0; + virtual void write(CAPRSFrame& frame) = 0; + virtual void clock(unsigned int ms) = 0; + virtual void stop() = 0; + virtual void addReadAPRSCallback(IReadAPRSFrameCallback* cb) = 0; +}; \ No newline at end of file diff --git a/DStarGateway/DStarGatewayApp.cpp b/DStarGateway/DStarGatewayApp.cpp index 8ce9864..76f9c3b 100644 --- a/DStarGateway/DStarGatewayApp.cpp +++ b/DStarGateway/DStarGatewayApp.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2010,2011 by Jonathan Naylor G4KLX - * Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA + * Copyright (c) 2021,2022 by Geoffrey Merck F4FXL / KC3FRA * * 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 @@ -48,6 +48,7 @@ #include "APRSGPSDIdFrameProvider.h" #include "APRSFixedIdFrameProvider.h" #include "Daemon.h" +#include "APRSHandlerThread.h" CDStarGatewayApp * CDStarGatewayApp::g_app = nullptr; const std::string BANNER_1 = CStringUtils::string_format("%s Copyright (C) %s\n", FULL_PRODUCT_NAME.c_str(), VENDOR_NAME.c_str()); @@ -194,13 +195,14 @@ bool CDStarGatewayApp::createThread() m_config->getAPRS(aprsConfig); CAPRSHandler * aprsWriter = NULL; if(aprsConfig.enabled && !aprsConfig.password.empty()) { - aprsWriter = new CAPRSHandler(aprsConfig.hostname, aprsConfig.port, gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address); + CAPRSHandlerThread* thread = new CAPRSHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); + aprsWriter = new CAPRSHandler((IAPRSHandlerThread *)thread); if(aprsWriter->open()) { #ifdef USE_GPSD - CAPRSIdFrameProvider * idFrameProvider = aprsConfig.m_positionSource == POSSRC_GPSD ? (CAPRSIdFrameProvider *)new CAPRSGPSDIdFrameProvider(gpsdConfig.m_address, gpsdConfig.m_port) - : new CAPRSFixedIdFrameProvider(); + CAPRSIdFrameProvider * idFrameProvider = aprsConfig.m_positionSource == POSSRC_GPSD ? (CAPRSIdFrameProvider *)new CAPRSGPSDIdFrameProvider(gatewayConfig.callsign, gpsdConfig.m_address, gpsdConfig.m_port) + : new CAPRSFixedIdFrameProvider(gatewayConfig.callsign); #else - CAPRSIdFrameProvider * idFrameProvider = new CAPRSFixedIdFrameProvider(); + CAPRSIdFrameProvider * idFrameProvider = new CAPRSFixedIdFrameProvider(gatewayConfig.callsign); #endif idFrameProvider->start(); aprsWriter->setIdFrameProvider(idFrameProvider); diff --git a/DStarGateway/DStarGatewayThread.cpp b/DStarGateway/DStarGatewayThread.cpp index 1d7d074..93b78bf 100644 --- a/DStarGateway/DStarGatewayThread.cpp +++ b/DStarGateway/DStarGatewayThread.cpp @@ -984,7 +984,7 @@ void CDStarGatewayThread::processDExtra() case DE_HEADER: { CHeaderData* header = m_dextraPool->readHeader(); if (header != NULL) { - // CLog::logInfo("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s", header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); + CLog::logInfo("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s", header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); CDExtraHandler::process(*header); delete header; } From ae2293103463942561c56a71b8522709ddd1579c Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 20:30:06 +0100 Subject: [PATCH 09/17] #29 handle incoming DPRS so that it shows up in log --- Common/DummyAPRSHandlerThread.cpp | 55 +++++++++++++++++++++++++++++ Common/DummyAPRSHandlerThread.h | 35 ++++++++++++++++++ Common/RepeaterHandler.cpp | 42 +++++++++++++--------- Common/RepeaterHandler.h | 5 +-- DStarGateway/DStarGatewayApp.cpp | 24 ++++++++----- DStarGateway/DStarGatewayThread.cpp | 46 ++++++++++++------------ DStarGateway/DStarGatewayThread.h | 5 +-- 7 files changed, 161 insertions(+), 51 deletions(-) create mode 100644 Common/DummyAPRSHandlerThread.cpp create mode 100644 Common/DummyAPRSHandlerThread.h diff --git a/Common/DummyAPRSHandlerThread.cpp b/Common/DummyAPRSHandlerThread.cpp new file mode 100644 index 0000000..1c9f007 --- /dev/null +++ b/Common/DummyAPRSHandlerThread.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021, 2022 by Geoffrey Merck F4FXL / KC3FRA + * + * 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 "DummyAPRSHandlerThread.h" + +CDummyAPRSHandlerThread::CDummyAPRSHandlerThread() +{ + +} + +CDummyAPRSHandlerThread::~CDummyAPRSHandlerThread() +{ + +} + +bool CDummyAPRSHandlerThread::start() +{ + return true; +} + +bool CDummyAPRSHandlerThread::isConnected() const +{ + return true; +} + +void CDummyAPRSHandlerThread::write(CAPRSFrame &) +{ +} + +void CDummyAPRSHandlerThread::clock(unsigned int) +{ +} + +void CDummyAPRSHandlerThread::stop() +{ +} + +void CDummyAPRSHandlerThread::addReadAPRSCallback(IReadAPRSFrameCallback *) +{ +} \ No newline at end of file diff --git a/Common/DummyAPRSHandlerThread.h b/Common/DummyAPRSHandlerThread.h new file mode 100644 index 0000000..94ff2e1 --- /dev/null +++ b/Common/DummyAPRSHandlerThread.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021, 2022 by Geoffrey Merck F4FXL / KC3FRA + * + * 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. + */ + +#pragma once + +#include "IAPRSHandlerThread.h" + +class CDummyAPRSHandlerThread : public IAPRSHandlerThread +{ +public: + CDummyAPRSHandlerThread(); + ~CDummyAPRSHandlerThread(); + + bool start(); + bool isConnected() const; + void write(CAPRSFrame& frame); + void clock(unsigned int ms); + void stop(); + void addReadAPRSCallback(IReadAPRSFrameCallback* cb); +}; \ No newline at end of file diff --git a/Common/RepeaterHandler.cpp b/Common/RepeaterHandler.cpp index c66e95f..4c119c2 100644 --- a/Common/RepeaterHandler.cpp +++ b/Common/RepeaterHandler.cpp @@ -59,7 +59,8 @@ bool CRepeaterHandler::m_dtmfEnabled = true; CHeaderLogger* CRepeaterHandler::m_headerLogger = NULL; -CAPRSHandler* CRepeaterHandler::m_aprsWriter = NULL; +CAPRSHandler* CRepeaterHandler::m_outgoingAprsWriter = NULL; +CAPRSHandler* CRepeaterHandler::m_incomingAprsWriter = NULL; CCallsignList* CRepeaterHandler::m_restrictList = NULL; @@ -352,9 +353,10 @@ void CRepeaterHandler::setHeaderLogger(CHeaderLogger* logger) m_headerLogger = logger; } -void CRepeaterHandler::setAPRSWriter(CAPRSHandler* writer) +void CRepeaterHandler::setAPRSWriters(CAPRSHandler* outgoingAprsWriter, CAPRSHandler* incomingAprsWriter) { - m_aprsWriter = writer; + m_outgoingAprsWriter = outgoingAprsWriter; + m_incomingAprsWriter = incomingAprsWriter; } void CRepeaterHandler::setLocalAddress(const std::string& address) @@ -613,8 +615,8 @@ void CRepeaterHandler::processRepeater(CHeaderData& header) m_text.clear(); // Reset the APRS Writer if it's enabled - if (m_aprsWriter != NULL) - m_aprsWriter->writeHeader(m_rptCallsign, header); + if (m_outgoingAprsWriter != NULL) + m_outgoingAprsWriter->writeHeader(m_rptCallsign, header); // Write to Header.log if it's enabled if (m_headerLogger != NULL) @@ -823,8 +825,8 @@ void CRepeaterHandler::processRepeater(CAMBEData& data) if (m_drats != NULL) m_drats->writeData(data); - if (m_aprsWriter != NULL) - m_aprsWriter->writeData(m_rptCallsign, data); + if (m_outgoingAprsWriter != NULL) + m_outgoingAprsWriter->writeData(m_rptCallsign, data); if (m_text.empty() && !data.isEnd()) { m_textCollector.writeData(data); @@ -1173,6 +1175,9 @@ bool CRepeaterHandler::process(CHeaderData& header, DIRECTION, AUDIO_SOURCE sour if (source == AS_DUP) return true; + if(m_incomingAprsWriter != nullptr) + m_incomingAprsWriter->writeHeader(m_rptCallsign, header); + sendToIncoming(header); #ifdef USE_CCS @@ -1212,6 +1217,9 @@ bool CRepeaterHandler::process(CAMBEData& data, DIRECTION, AUDIO_SOURCE source) m_repeaterHandler->writeAMBE(data); + if(m_incomingAprsWriter != nullptr) + m_incomingAprsWriter->writeData(m_rptCallsign, data); + sendToIncoming(data); #ifdef USE_CCS @@ -2413,8 +2421,8 @@ void CRepeaterHandler::startupInt() m_irc->rptrQTH(callsign, m_latitude, m_longitude, m_description1, m_description2, m_url); } - if(m_aprsWriter != nullptr) { - m_aprsWriter->addReadAPRSCallback(this); + if(m_outgoingAprsWriter != nullptr) { + m_outgoingAprsWriter->addReadAPRSCallback(this); } #ifdef USE_CCS @@ -2564,8 +2572,8 @@ void CRepeaterHandler::writeLinkingTo(const std::string &callsign) m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_aprsWriter != nullptr) - m_aprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsWriter != nullptr) + m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); @@ -2619,8 +2627,8 @@ void CRepeaterHandler::writeLinkedTo(const std::string &callsign) m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_aprsWriter != nullptr) - m_aprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsWriter != nullptr) + m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(callsign); @@ -2674,8 +2682,8 @@ void CRepeaterHandler::writeNotLinked() m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_aprsWriter != nullptr) - m_aprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsWriter != nullptr) + m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); @@ -2745,8 +2753,8 @@ void CRepeaterHandler::writeIsBusy(const std::string& callsign) m_infoAudio->setTempStatus(m_linkStatus, m_linkRepeater, tempText); triggerInfo(); - if(m_aprsWriter != nullptr) - m_aprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsWriter != nullptr) + m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); diff --git a/Common/RepeaterHandler.h b/Common/RepeaterHandler.h index e0422c4..5c34d3c 100644 --- a/Common/RepeaterHandler.h +++ b/Common/RepeaterHandler.h @@ -74,7 +74,7 @@ public: static void setDPlusEnabled(bool enabled); static void setDCSEnabled(bool enabled); static void setHeaderLogger(CHeaderLogger* logger); - static void setAPRSWriter(CAPRSHandler* writer); + static void setAPRSWriters(CAPRSHandler* outgoingAprsWriter, CAPRSHandler* incomingAprsWriter); static void setInfoEnabled(bool enabled); static void setEchoEnabled(bool enabled); static void setDTMFEnabled(bool enabled); @@ -169,7 +169,8 @@ private: static CHeaderLogger* m_headerLogger; - static CAPRSHandler* m_aprsWriter; + static CAPRSHandler* m_outgoingAprsWriter; + static CAPRSHandler* m_incomingAprsWriter; static CCallsignList* m_whiteList; static CCallsignList* m_blackList; diff --git a/DStarGateway/DStarGatewayApp.cpp b/DStarGateway/DStarGatewayApp.cpp index 76f9c3b..2efc783 100644 --- a/DStarGateway/DStarGatewayApp.cpp +++ b/DStarGateway/DStarGatewayApp.cpp @@ -49,6 +49,7 @@ #include "APRSFixedIdFrameProvider.h" #include "Daemon.h" #include "APRSHandlerThread.h" +#include "DummyAPRSHandlerThread.h" CDStarGatewayApp * CDStarGatewayApp::g_app = nullptr; const std::string BANNER_1 = CStringUtils::string_format("%s Copyright (C) %s\n", FULL_PRODUCT_NAME.c_str(), VENDOR_NAME.c_str()); @@ -193,11 +194,15 @@ bool CDStarGatewayApp::createThread() // Setup APRS TAPRS aprsConfig; m_config->getAPRS(aprsConfig); - CAPRSHandler * aprsWriter = NULL; + CAPRSHandler * outgoingAprsWriter = nullptr; + CAPRSHandler * incomingAprsWriter = nullptr; if(aprsConfig.enabled && !aprsConfig.password.empty()) { CAPRSHandlerThread* thread = new CAPRSHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); - aprsWriter = new CAPRSHandler((IAPRSHandlerThread *)thread); - if(aprsWriter->open()) { + outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerThread *)thread); + + incomingAprsWriter = new CAPRSHandler((IAPRSHandlerThread *)new CDummyAPRSHandlerThread()); + + if(outgoingAprsWriter->open()) { #ifdef USE_GPSD CAPRSIdFrameProvider * idFrameProvider = aprsConfig.m_positionSource == POSSRC_GPSD ? (CAPRSIdFrameProvider *)new CAPRSGPSDIdFrameProvider(gatewayConfig.callsign, gpsdConfig.m_address, gpsdConfig.m_port) : new CAPRSFixedIdFrameProvider(gatewayConfig.callsign); @@ -205,12 +210,12 @@ bool CDStarGatewayApp::createThread() CAPRSIdFrameProvider * idFrameProvider = new CAPRSFixedIdFrameProvider(gatewayConfig.callsign); #endif idFrameProvider->start(); - aprsWriter->setIdFrameProvider(idFrameProvider); - m_thread->setAPRSWriter(aprsWriter); + outgoingAprsWriter->setIdFrameProvider(idFrameProvider); + m_thread->setAPRSWriters(outgoingAprsWriter, incomingAprsWriter); } else { - delete aprsWriter; - aprsWriter = NULL; + delete outgoingAprsWriter; + outgoingAprsWriter = NULL; } } @@ -280,7 +285,10 @@ bool CDStarGatewayApp::createThread() rptrConfig.band2, rptrConfig.band3); - aprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl); + if(outgoingAprsWriter != nullptr) + outgoingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl); + if(incomingAprsWriter != nullptr) + incomingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl); if(!ddEnabled) ddEnabled = rptrConfig.band.length() > 1U; } diff --git a/DStarGateway/DStarGatewayThread.cpp b/DStarGateway/DStarGatewayThread.cpp index 93b78bf..c7fd212 100644 --- a/DStarGateway/DStarGatewayThread.cpp +++ b/DStarGateway/DStarGatewayThread.cpp @@ -69,15 +69,16 @@ m_stopped(true), m_gatewayType(GT_REPEATER), m_gatewayCallsign(), m_gatewayAddress(), -m_icomRepeaterHandler(NULL), -m_hbRepeaterHandler(NULL), -m_dummyRepeaterHandler(NULL), -m_dextraPool(NULL), -m_dplusPool(NULL), -m_dcsPool(NULL), -m_g2HandlerPool(NULL), -m_aprsWriter(NULL), -m_irc(NULL), +m_icomRepeaterHandler(nullptr), +m_hbRepeaterHandler(nullptr), +m_dummyRepeaterHandler(nullptr), +m_dextraPool(nullptr), +m_dplusPool(nullptr), +m_dcsPool(nullptr), +m_g2HandlerPool(nullptr), +m_outgoingAprsWriter(nullptr), +m_incomingAprsWriter(nullptr), +m_irc(nullptr), m_cache(), m_language(TL_ENGLISH_UK), m_dextraEnabled(true), @@ -110,9 +111,9 @@ m_status4(), m_status5(), m_latitude(0.0), m_longitude(0.0), -m_whiteList(NULL), -m_blackList(NULL), -m_restrictList(NULL) +m_whiteList(nullptr), +m_blackList(nullptr), +m_restrictList(nullptr) { CHeaderData::initialise(); CG2Handler::initialise(MAX_ROUTES); @@ -250,7 +251,7 @@ void* CDStarGatewayThread::Entry() CRepeaterHandler::setDPlusEnabled(m_dplusEnabled); CRepeaterHandler::setDCSEnabled(m_dcsEnabled); CRepeaterHandler::setHeaderLogger(headerLogger); - CRepeaterHandler::setAPRSWriter(m_aprsWriter); + CRepeaterHandler::setAPRSWriters(m_outgoingAprsWriter, m_incomingAprsWriter); CRepeaterHandler::setInfoEnabled(m_infoEnabled); CRepeaterHandler::setEchoEnabled(m_echoEnabled); CRepeaterHandler::setDTMFEnabled(m_dtmfEnabled); @@ -377,8 +378,8 @@ void* CDStarGatewayThread::Entry() m_statusFileTimer.start(); } - if (m_aprsWriter != NULL) - m_aprsWriter->clock(ms); + if (m_outgoingAprsWriter != NULL) + m_outgoingAprsWriter->clock(ms); if (m_logEnabled) { m_statusTimer1.clock(ms); @@ -469,9 +470,9 @@ void* CDStarGatewayThread::Entry() delete m_remote; } - if(m_aprsWriter != nullptr) { - m_aprsWriter->close(); - delete m_aprsWriter; + if(m_outgoingAprsWriter != nullptr) { + m_outgoingAprsWriter->close(); + delete m_outgoingAprsWriter; } if (headerLogger != NULL) { @@ -636,9 +637,10 @@ void CDStarGatewayThread::setLog(bool enabled) m_logEnabled = enabled; } -void CDStarGatewayThread::setAPRSWriter(CAPRSHandler* writer) +void CDStarGatewayThread::setAPRSWriters(CAPRSHandler* outgoingWriter, CAPRSHandler* incomingWriter) { - m_aprsWriter = writer; + m_outgoingAprsWriter = outgoingWriter; + m_incomingAprsWriter = incomingWriter; } void CDStarGatewayThread::setInfoEnabled(bool enabled) @@ -1244,8 +1246,8 @@ void CDStarGatewayThread::writeStatus() CDStarGatewayStatusData* CDStarGatewayThread::getStatus() const { bool aprsStatus = false; - if (m_aprsWriter != NULL) - aprsStatus = m_aprsWriter->isConnected(); + if (m_outgoingAprsWriter != NULL) + aprsStatus = m_outgoingAprsWriter->isConnected(); CDStarGatewayStatusData* status = new CDStarGatewayStatusData(m_lastStatus, aprsStatus); diff --git a/DStarGateway/DStarGatewayThread.h b/DStarGateway/DStarGatewayThread.h index 767a81d..83dddaf 100644 --- a/DStarGateway/DStarGatewayThread.h +++ b/DStarGateway/DStarGatewayThread.h @@ -66,7 +66,7 @@ public: virtual void setCCS(bool enabled, const std::string& host); #endif virtual void setLog(bool enabled); - virtual void setAPRSWriter(CAPRSHandler* writer); + virtual void setAPRSWriters(CAPRSHandler* outgoingAprsWriter, CAPRSHandler* incomingAPRSHandler); virtual void setInfoEnabled(bool enabled); virtual void setEchoEnabled(bool enabled); virtual void setDTMFEnabled(bool enabled); @@ -100,7 +100,8 @@ private: CDPlusProtocolHandlerPool* m_dplusPool; CDCSProtocolHandlerPool* m_dcsPool; CG2ProtocolHandlerPool* m_g2HandlerPool; - CAPRSHandler* m_aprsWriter; + CAPRSHandler* m_outgoingAprsWriter; + CAPRSHandler* m_incomingAprsWriter; CIRCDDB* m_irc; CCacheManager m_cache; TEXT_LANG m_language; From e62ab369b1721825145b1345c930ea574d6b44e4 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Wed, 28 Dec 2022 20:30:56 +0100 Subject: [PATCH 10/17] #29 comment log output --- DStarGateway/DStarGatewayThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DStarGateway/DStarGatewayThread.cpp b/DStarGateway/DStarGatewayThread.cpp index c7fd212..75182ef 100644 --- a/DStarGateway/DStarGatewayThread.cpp +++ b/DStarGateway/DStarGatewayThread.cpp @@ -986,7 +986,7 @@ void CDStarGatewayThread::processDExtra() case DE_HEADER: { CHeaderData* header = m_dextraPool->readHeader(); if (header != NULL) { - CLog::logInfo("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s", header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); + // CLog::logInfo("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s", header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); CDExtraHandler::process(*header); delete header; } From 135259745fa422ed3ea2be498762c91b1139a4b0 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Thu, 29 Dec 2022 11:32:33 +0100 Subject: [PATCH 11/17] #29 rename APRSWriters variables --- Common/RepeaterHandler.cpp | 46 ++++++++++++++--------------- Common/RepeaterHandler.h | 6 ++-- DStarGateway/DStarGatewayThread.cpp | 24 +++++++-------- DStarGateway/DStarGatewayThread.h | 4 +-- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Common/RepeaterHandler.cpp b/Common/RepeaterHandler.cpp index 4c119c2..b6573df 100644 --- a/Common/RepeaterHandler.cpp +++ b/Common/RepeaterHandler.cpp @@ -59,8 +59,8 @@ bool CRepeaterHandler::m_dtmfEnabled = true; CHeaderLogger* CRepeaterHandler::m_headerLogger = NULL; -CAPRSHandler* CRepeaterHandler::m_outgoingAprsWriter = NULL; -CAPRSHandler* CRepeaterHandler::m_incomingAprsWriter = NULL; +CAPRSHandler* CRepeaterHandler::m_outgoingAprsHandler = NULL; +CAPRSHandler* CRepeaterHandler::m_incomingAprsHandler = NULL; CCallsignList* CRepeaterHandler::m_restrictList = NULL; @@ -353,10 +353,10 @@ void CRepeaterHandler::setHeaderLogger(CHeaderLogger* logger) m_headerLogger = logger; } -void CRepeaterHandler::setAPRSWriters(CAPRSHandler* outgoingAprsWriter, CAPRSHandler* incomingAprsWriter) +void CRepeaterHandler::setAPRSHandlers(CAPRSHandler* outgoingAprsHandler, CAPRSHandler* incomingAprsHandler) { - m_outgoingAprsWriter = outgoingAprsWriter; - m_incomingAprsWriter = incomingAprsWriter; + m_outgoingAprsHandler = outgoingAprsHandler; + m_incomingAprsHandler = incomingAprsHandler; } void CRepeaterHandler::setLocalAddress(const std::string& address) @@ -615,8 +615,8 @@ void CRepeaterHandler::processRepeater(CHeaderData& header) m_text.clear(); // Reset the APRS Writer if it's enabled - if (m_outgoingAprsWriter != NULL) - m_outgoingAprsWriter->writeHeader(m_rptCallsign, header); + if (m_outgoingAprsHandler != NULL) + m_outgoingAprsHandler->writeHeader(m_rptCallsign, header); // Write to Header.log if it's enabled if (m_headerLogger != NULL) @@ -825,8 +825,8 @@ void CRepeaterHandler::processRepeater(CAMBEData& data) if (m_drats != NULL) m_drats->writeData(data); - if (m_outgoingAprsWriter != NULL) - m_outgoingAprsWriter->writeData(m_rptCallsign, data); + if (m_outgoingAprsHandler != NULL) + m_outgoingAprsHandler->writeData(m_rptCallsign, data); if (m_text.empty() && !data.isEnd()) { m_textCollector.writeData(data); @@ -1175,8 +1175,8 @@ bool CRepeaterHandler::process(CHeaderData& header, DIRECTION, AUDIO_SOURCE sour if (source == AS_DUP) return true; - if(m_incomingAprsWriter != nullptr) - m_incomingAprsWriter->writeHeader(m_rptCallsign, header); + if(m_incomingAprsHandler != nullptr) + m_incomingAprsHandler->writeHeader(m_rptCallsign, header); sendToIncoming(header); @@ -1217,8 +1217,8 @@ bool CRepeaterHandler::process(CAMBEData& data, DIRECTION, AUDIO_SOURCE source) m_repeaterHandler->writeAMBE(data); - if(m_incomingAprsWriter != nullptr) - m_incomingAprsWriter->writeData(m_rptCallsign, data); + if(m_incomingAprsHandler != nullptr) + m_incomingAprsHandler->writeData(m_rptCallsign, data); sendToIncoming(data); @@ -2421,8 +2421,8 @@ void CRepeaterHandler::startupInt() m_irc->rptrQTH(callsign, m_latitude, m_longitude, m_description1, m_description2, m_url); } - if(m_outgoingAprsWriter != nullptr) { - m_outgoingAprsWriter->addReadAPRSCallback(this); + if(m_outgoingAprsHandler != nullptr) { + m_outgoingAprsHandler->addReadAPRSCallback(this); } #ifdef USE_CCS @@ -2572,8 +2572,8 @@ void CRepeaterHandler::writeLinkingTo(const std::string &callsign) m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_outgoingAprsWriter != nullptr) - m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsHandler != nullptr) + m_outgoingAprsHandler->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); @@ -2627,8 +2627,8 @@ void CRepeaterHandler::writeLinkedTo(const std::string &callsign) m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_outgoingAprsWriter != nullptr) - m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsHandler != nullptr) + m_outgoingAprsHandler->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(callsign); @@ -2682,8 +2682,8 @@ void CRepeaterHandler::writeNotLinked() m_infoAudio->setStatus(m_linkStatus, m_linkRepeater, text); triggerInfo(); - if(m_outgoingAprsWriter != nullptr) - m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsHandler != nullptr) + m_outgoingAprsHandler->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); @@ -2753,8 +2753,8 @@ void CRepeaterHandler::writeIsBusy(const std::string& callsign) m_infoAudio->setTempStatus(m_linkStatus, m_linkRepeater, tempText); triggerInfo(); - if(m_outgoingAprsWriter != nullptr) - m_outgoingAprsWriter->writeStatus(m_rptCallsign, text); + if(m_outgoingAprsHandler != nullptr) + m_outgoingAprsHandler->writeStatus(m_rptCallsign, text); #ifdef USE_CCS m_ccsHandler->setReflector(); diff --git a/Common/RepeaterHandler.h b/Common/RepeaterHandler.h index 5c34d3c..c5ed834 100644 --- a/Common/RepeaterHandler.h +++ b/Common/RepeaterHandler.h @@ -74,7 +74,7 @@ public: static void setDPlusEnabled(bool enabled); static void setDCSEnabled(bool enabled); static void setHeaderLogger(CHeaderLogger* logger); - static void setAPRSWriters(CAPRSHandler* outgoingAprsWriter, CAPRSHandler* incomingAprsWriter); + static void setAPRSHandlers(CAPRSHandler* outgoingAprsHandler, CAPRSHandler* incomingAprsHandler); static void setInfoEnabled(bool enabled); static void setEchoEnabled(bool enabled); static void setDTMFEnabled(bool enabled); @@ -169,8 +169,8 @@ private: static CHeaderLogger* m_headerLogger; - static CAPRSHandler* m_outgoingAprsWriter; - static CAPRSHandler* m_incomingAprsWriter; + static CAPRSHandler* m_outgoingAprsHandler; + static CAPRSHandler* m_incomingAprsHandler; static CCallsignList* m_whiteList; static CCallsignList* m_blackList; diff --git a/DStarGateway/DStarGatewayThread.cpp b/DStarGateway/DStarGatewayThread.cpp index 75182ef..3f4c218 100644 --- a/DStarGateway/DStarGatewayThread.cpp +++ b/DStarGateway/DStarGatewayThread.cpp @@ -76,8 +76,8 @@ m_dextraPool(nullptr), m_dplusPool(nullptr), m_dcsPool(nullptr), m_g2HandlerPool(nullptr), -m_outgoingAprsWriter(nullptr), -m_incomingAprsWriter(nullptr), +m_outgoingAprsHandler(nullptr), +m_incomingAprsHandler(nullptr), m_irc(nullptr), m_cache(), m_language(TL_ENGLISH_UK), @@ -251,7 +251,7 @@ void* CDStarGatewayThread::Entry() CRepeaterHandler::setDPlusEnabled(m_dplusEnabled); CRepeaterHandler::setDCSEnabled(m_dcsEnabled); CRepeaterHandler::setHeaderLogger(headerLogger); - CRepeaterHandler::setAPRSWriters(m_outgoingAprsWriter, m_incomingAprsWriter); + CRepeaterHandler::setAPRSHandlers(m_outgoingAprsHandler, m_incomingAprsHandler); CRepeaterHandler::setInfoEnabled(m_infoEnabled); CRepeaterHandler::setEchoEnabled(m_echoEnabled); CRepeaterHandler::setDTMFEnabled(m_dtmfEnabled); @@ -378,8 +378,8 @@ void* CDStarGatewayThread::Entry() m_statusFileTimer.start(); } - if (m_outgoingAprsWriter != NULL) - m_outgoingAprsWriter->clock(ms); + if (m_outgoingAprsHandler != NULL) + m_outgoingAprsHandler->clock(ms); if (m_logEnabled) { m_statusTimer1.clock(ms); @@ -470,9 +470,9 @@ void* CDStarGatewayThread::Entry() delete m_remote; } - if(m_outgoingAprsWriter != nullptr) { - m_outgoingAprsWriter->close(); - delete m_outgoingAprsWriter; + if(m_outgoingAprsHandler != nullptr) { + m_outgoingAprsHandler->close(); + delete m_outgoingAprsHandler; } if (headerLogger != NULL) { @@ -639,8 +639,8 @@ void CDStarGatewayThread::setLog(bool enabled) void CDStarGatewayThread::setAPRSWriters(CAPRSHandler* outgoingWriter, CAPRSHandler* incomingWriter) { - m_outgoingAprsWriter = outgoingWriter; - m_incomingAprsWriter = incomingWriter; + m_outgoingAprsHandler = outgoingWriter; + m_incomingAprsHandler = incomingWriter; } void CDStarGatewayThread::setInfoEnabled(bool enabled) @@ -1246,8 +1246,8 @@ void CDStarGatewayThread::writeStatus() CDStarGatewayStatusData* CDStarGatewayThread::getStatus() const { bool aprsStatus = false; - if (m_outgoingAprsWriter != NULL) - aprsStatus = m_outgoingAprsWriter->isConnected(); + if (m_outgoingAprsHandler != NULL) + aprsStatus = m_outgoingAprsHandler->isConnected(); CDStarGatewayStatusData* status = new CDStarGatewayStatusData(m_lastStatus, aprsStatus); diff --git a/DStarGateway/DStarGatewayThread.h b/DStarGateway/DStarGatewayThread.h index 83dddaf..26a799b 100644 --- a/DStarGateway/DStarGatewayThread.h +++ b/DStarGateway/DStarGatewayThread.h @@ -100,8 +100,8 @@ private: CDPlusProtocolHandlerPool* m_dplusPool; CDCSProtocolHandlerPool* m_dcsPool; CG2ProtocolHandlerPool* m_g2HandlerPool; - CAPRSHandler* m_outgoingAprsWriter; - CAPRSHandler* m_incomingAprsWriter; + CAPRSHandler* m_outgoingAprsHandler; + CAPRSHandler* m_incomingAprsHandler; CIRCDDB* m_irc; CCacheManager m_cache; TEXT_LANG m_language; From c5624eea3aa3a0ab38c6933d8c4c0646012b8329 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Thu, 29 Dec 2022 11:34:16 +0100 Subject: [PATCH 12/17] #29 move circleCI status to the top of README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2807ff7..7e2255d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![F4FXL](https://circleci.com/gh/F4FXL/DStarGateway.svg?style=svg)](https://app.circleci.com/pipelines/github/F4FXL/DStarGateway?filter=all) - [1. Introduction](#1-introduction) - [2. Current State](#2-current-state) - [2.1. Code sanity](#21-code-sanity) From 2076f4f4344d688f85a0dd055a14aa24e090823b Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Thu, 29 Dec 2022 11:39:10 +0100 Subject: [PATCH 13/17] #29 rename abstract class to backend --- Common/APRSHandler.cpp | 2 +- Common/APRSHandler.h | 6 +++--- Common/APRSHandlerThread.h | 4 ++-- Common/DummyAPRSHandlerThread.h | 4 ++-- Common/{IAPRSHandlerThread.h => IAPRSHandlerBackend.h} | 4 ++-- DStarGateway/DStarGatewayApp.cpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) rename Common/{IAPRSHandlerThread.h => IAPRSHandlerBackend.h} (94%) diff --git a/Common/APRSHandler.cpp b/Common/APRSHandler.cpp index 50dd130..ab84f53 100644 --- a/Common/APRSHandler.cpp +++ b/Common/APRSHandler.cpp @@ -33,7 +33,7 @@ #include "APRSFormater.h" #include "APRSUtils.h" -CAPRSHandler::CAPRSHandler(IAPRSHandlerThread* thread) : +CAPRSHandler::CAPRSHandler(IAPRSHandlerBackend* thread) : m_thread(thread), m_array(), m_idFrameProvider(nullptr) diff --git a/Common/APRSHandler.h b/Common/APRSHandler.h index 0958d0a..f4876e5 100644 --- a/Common/APRSHandler.h +++ b/Common/APRSHandler.h @@ -33,11 +33,11 @@ #include "AMBEData.h" #include "Timer.h" #include "APRSIdFrameProvider.h" -#include "IAPRSHandlerThread.h" +#include "IAPRSHandlerBackend.h" class CAPRSHandler { public: - CAPRSHandler(IAPRSHandlerThread * thread); + CAPRSHandler(IAPRSHandlerBackend * thread); ~CAPRSHandler(); bool open(); @@ -61,7 +61,7 @@ public: void addReadAPRSCallback(IReadAPRSFrameCallback* cb); private: - IAPRSHandlerThread* m_thread; + IAPRSHandlerBackend* m_thread; std::unordered_map m_array; CAPRSIdFrameProvider * m_idFrameProvider; diff --git a/Common/APRSHandlerThread.h b/Common/APRSHandlerThread.h index fdeef68..3cff8c5 100644 --- a/Common/APRSHandlerThread.h +++ b/Common/APRSHandlerThread.h @@ -25,11 +25,11 @@ #include "RingBuffer.h" #include "Timer.h" #include "Thread.h" -#include "IAPRSHandlerThread.h" +#include "IAPRSHandlerBackend.h" #include "APRSFrame.h" -class CAPRSHandlerThread : public CThread, IAPRSHandlerThread { +class CAPRSHandlerThread : public CThread, IAPRSHandlerBackend { public: CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port); CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter); diff --git a/Common/DummyAPRSHandlerThread.h b/Common/DummyAPRSHandlerThread.h index 94ff2e1..9ae91f2 100644 --- a/Common/DummyAPRSHandlerThread.h +++ b/Common/DummyAPRSHandlerThread.h @@ -18,9 +18,9 @@ #pragma once -#include "IAPRSHandlerThread.h" +#include "IAPRSHandlerBackend.h" -class CDummyAPRSHandlerThread : public IAPRSHandlerThread +class CDummyAPRSHandlerThread : public IAPRSHandlerBackend { public: CDummyAPRSHandlerThread(); diff --git a/Common/IAPRSHandlerThread.h b/Common/IAPRSHandlerBackend.h similarity index 94% rename from Common/IAPRSHandlerThread.h rename to Common/IAPRSHandlerBackend.h index 991f8f5..e06f10f 100644 --- a/Common/IAPRSHandlerThread.h +++ b/Common/IAPRSHandlerBackend.h @@ -21,10 +21,10 @@ #include "APRSFrame.h" #include "ReadAPRSFrameCallback.h" -class IAPRSHandlerThread +class IAPRSHandlerBackend { public: - virtual ~IAPRSHandlerThread() { } ; + virtual ~IAPRSHandlerBackend() { } ; virtual bool start() = 0; virtual bool isConnected() const = 0; diff --git a/DStarGateway/DStarGatewayApp.cpp b/DStarGateway/DStarGatewayApp.cpp index 2efc783..0e8fd44 100644 --- a/DStarGateway/DStarGatewayApp.cpp +++ b/DStarGateway/DStarGatewayApp.cpp @@ -198,9 +198,9 @@ bool CDStarGatewayApp::createThread() CAPRSHandler * incomingAprsWriter = nullptr; if(aprsConfig.enabled && !aprsConfig.password.empty()) { CAPRSHandlerThread* thread = new CAPRSHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); - outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerThread *)thread); + outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)thread); - incomingAprsWriter = new CAPRSHandler((IAPRSHandlerThread *)new CDummyAPRSHandlerThread()); + incomingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)new CDummyAPRSHandlerThread()); if(outgoingAprsWriter->open()) { #ifdef USE_GPSD From 5d383b82570f4b15e4f70c589ddf4edda9fb6924 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Thu, 29 Dec 2022 15:50:51 +0100 Subject: [PATCH 14/17] #29 some more renaming --- Common/DummyAPRSHandlerThread.cpp | 16 ++++++++-------- Common/DummyAPRSHandlerThread.h | 6 +++--- DStarGateway/DStarGatewayApp.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Common/DummyAPRSHandlerThread.cpp b/Common/DummyAPRSHandlerThread.cpp index 1c9f007..c404fe0 100644 --- a/Common/DummyAPRSHandlerThread.cpp +++ b/Common/DummyAPRSHandlerThread.cpp @@ -18,38 +18,38 @@ #include "DummyAPRSHandlerThread.h" -CDummyAPRSHandlerThread::CDummyAPRSHandlerThread() +CDummyAPRSHandlerBackend::CDummyAPRSHandlerBackend() { } -CDummyAPRSHandlerThread::~CDummyAPRSHandlerThread() +CDummyAPRSHandlerBackend::~CDummyAPRSHandlerBackend() { } -bool CDummyAPRSHandlerThread::start() +bool CDummyAPRSHandlerBackend::start() { return true; } -bool CDummyAPRSHandlerThread::isConnected() const +bool CDummyAPRSHandlerBackend::isConnected() const { return true; } -void CDummyAPRSHandlerThread::write(CAPRSFrame &) +void CDummyAPRSHandlerBackend::write(CAPRSFrame &) { } -void CDummyAPRSHandlerThread::clock(unsigned int) +void CDummyAPRSHandlerBackend::clock(unsigned int) { } -void CDummyAPRSHandlerThread::stop() +void CDummyAPRSHandlerBackend::stop() { } -void CDummyAPRSHandlerThread::addReadAPRSCallback(IReadAPRSFrameCallback *) +void CDummyAPRSHandlerBackend::addReadAPRSCallback(IReadAPRSFrameCallback *) { } \ No newline at end of file diff --git a/Common/DummyAPRSHandlerThread.h b/Common/DummyAPRSHandlerThread.h index 9ae91f2..3401813 100644 --- a/Common/DummyAPRSHandlerThread.h +++ b/Common/DummyAPRSHandlerThread.h @@ -20,11 +20,11 @@ #include "IAPRSHandlerBackend.h" -class CDummyAPRSHandlerThread : public IAPRSHandlerBackend +class CDummyAPRSHandlerBackend : public IAPRSHandlerBackend { public: - CDummyAPRSHandlerThread(); - ~CDummyAPRSHandlerThread(); + CDummyAPRSHandlerBackend(); + ~CDummyAPRSHandlerBackend(); bool start(); bool isConnected() const; diff --git a/DStarGateway/DStarGatewayApp.cpp b/DStarGateway/DStarGatewayApp.cpp index 0e8fd44..e218e12 100644 --- a/DStarGateway/DStarGatewayApp.cpp +++ b/DStarGateway/DStarGatewayApp.cpp @@ -200,7 +200,7 @@ bool CDStarGatewayApp::createThread() CAPRSHandlerThread* thread = new CAPRSHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)thread); - incomingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)new CDummyAPRSHandlerThread()); + incomingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)new CDummyAPRSHandlerBackend()); if(outgoingAprsWriter->open()) { #ifdef USE_GPSD From c408201eb62bc8c67afce1e4288dc6b89cd5bea7 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 18 Feb 2023 08:34:02 +0100 Subject: [PATCH 15/17] Rename APRSHandlerThread to APRSISHandlerThread #29 --- ...dlerThread.cpp => APRSISHandlerThread.cpp} | 26 +++++++++---------- ...SHandlerThread.h => APRSISHandlerThread.h} | 8 +++--- Common/RepeaterHandler.cpp | 4 +-- DStarGateway/DStarGatewayApp.cpp | 6 ++--- 4 files changed, 22 insertions(+), 22 deletions(-) rename Common/{APRSHandlerThread.cpp => APRSISHandlerThread.cpp} (89%) rename Common/{APRSHandlerThread.h => APRSISHandlerThread.h} (80%) diff --git a/Common/APRSHandlerThread.cpp b/Common/APRSISHandlerThread.cpp similarity index 89% rename from Common/APRSHandlerThread.cpp rename to Common/APRSISHandlerThread.cpp index 494e474..a060fe1 100644 --- a/Common/APRSHandlerThread.cpp +++ b/Common/APRSISHandlerThread.cpp @@ -21,7 +21,7 @@ #include #include -#include "APRSHandlerThread.h" +#include "APRSISHandlerThread.h" #include "DStarDefines.h" #include "Utils.h" #include "Defs.h" @@ -36,7 +36,7 @@ const unsigned int APRS_TIMEOUT = 10U; const unsigned int APRS_READ_TIMEOUT = 1U; const unsigned int APRS_KEEP_ALIVE_TIMEOUT = 60U; -CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port) : +CAPRSISHandlerThread::CAPRSISHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port) : CThread("APRS"), m_username(callsign), m_password(password), @@ -64,7 +64,7 @@ m_clientName(FULL_PRODUCT_NAME) m_ssid = m_ssid.substr(LONG_CALLSIGN_LENGTH - 1U, 1); } -CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter) : +CAPRSISHandlerThread::CAPRSISHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter) : CThread("APRS"), m_username(callsign), m_password(password), @@ -92,7 +92,7 @@ m_clientName(FULL_PRODUCT_NAME) m_ssid = m_ssid.substr(LONG_CALLSIGN_LENGTH - 1U, 1); } -CAPRSHandlerThread::~CAPRSHandlerThread() +CAPRSISHandlerThread::~CAPRSISHandlerThread() { std::vector callBacksCopy; callBacksCopy.assign(m_APRSReadCallbacks.begin(), m_APRSReadCallbacks.end()); @@ -105,7 +105,7 @@ CAPRSHandlerThread::~CAPRSHandlerThread() m_password.clear(); } -bool CAPRSHandlerThread::start() +bool CAPRSISHandlerThread::start() { Create(); Run(); @@ -113,7 +113,7 @@ bool CAPRSHandlerThread::start() return true; } -void* CAPRSHandlerThread::Entry() +void* CAPRSISHandlerThread::Entry() { CLog::logInfo("Starting the APRS Writer thread"); @@ -214,13 +214,13 @@ void* CAPRSHandlerThread::Entry() return NULL; } -void CAPRSHandlerThread::addReadAPRSCallback(IReadAPRSFrameCallback * cb) +void CAPRSISHandlerThread::addReadAPRSCallback(IReadAPRSFrameCallback * cb) { assert(cb != nullptr); m_APRSReadCallbacks.push_back(cb); } -void CAPRSHandlerThread::write(CAPRSFrame& frame) +void CAPRSISHandlerThread::write(CAPRSFrame& frame) { if (!m_connected) return; @@ -235,25 +235,25 @@ void CAPRSHandlerThread::write(CAPRSFrame& frame) } } -bool CAPRSHandlerThread::isConnected() const +bool CAPRSISHandlerThread::isConnected() const { return m_connected; } -void CAPRSHandlerThread::stop() +void CAPRSISHandlerThread::stop() { m_exit = true; Wait(); } -void CAPRSHandlerThread::clock(unsigned int ms) +void CAPRSISHandlerThread::clock(unsigned int ms) { m_reconnectTimer.clock(ms); m_keepAliveTimer.clock(ms); } -bool CAPRSHandlerThread::connect() +bool CAPRSISHandlerThread::connect() { m_socket.close(); bool ret = m_socket.open(); @@ -304,7 +304,7 @@ bool CAPRSHandlerThread::connect() return true; } -void CAPRSHandlerThread::startReconnectionTimer() +void CAPRSISHandlerThread::startReconnectionTimer() { // Clamp at a ten minutes reconnect time m_tries++; diff --git a/Common/APRSHandlerThread.h b/Common/APRSISHandlerThread.h similarity index 80% rename from Common/APRSHandlerThread.h rename to Common/APRSISHandlerThread.h index 3cff8c5..4be743e 100644 --- a/Common/APRSHandlerThread.h +++ b/Common/APRSISHandlerThread.h @@ -29,11 +29,11 @@ #include "APRSFrame.h" -class CAPRSHandlerThread : public CThread, IAPRSHandlerBackend { +class CAPRSISHandlerThread : public CThread, IAPRSHandlerBackend { public: - CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port); - CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter); - virtual ~CAPRSHandlerThread(); + CAPRSISHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port); + CAPRSISHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter); + virtual ~CAPRSISHandlerThread(); bool start(); diff --git a/Common/RepeaterHandler.cpp b/Common/RepeaterHandler.cpp index b6573df..3fbb913 100644 --- a/Common/RepeaterHandler.cpp +++ b/Common/RepeaterHandler.cpp @@ -59,8 +59,8 @@ bool CRepeaterHandler::m_dtmfEnabled = true; CHeaderLogger* CRepeaterHandler::m_headerLogger = NULL; -CAPRSHandler* CRepeaterHandler::m_outgoingAprsHandler = NULL; -CAPRSHandler* CRepeaterHandler::m_incomingAprsHandler = NULL; +CAPRSHandler* CRepeaterHandler::m_outgoingAprsHandler = NULL; //handles APRS/DPRS frames coming from radio to network +CAPRSHandler* CRepeaterHandler::m_incomingAprsHandler = NULL; //handles APRS/DPRS frames coming from network to radio CCallsignList* CRepeaterHandler::m_restrictList = NULL; diff --git a/DStarGateway/DStarGatewayApp.cpp b/DStarGateway/DStarGatewayApp.cpp index e218e12..a62550b 100644 --- a/DStarGateway/DStarGatewayApp.cpp +++ b/DStarGateway/DStarGatewayApp.cpp @@ -48,7 +48,7 @@ #include "APRSGPSDIdFrameProvider.h" #include "APRSFixedIdFrameProvider.h" #include "Daemon.h" -#include "APRSHandlerThread.h" +#include "APRSISHandlerThread.h" #include "DummyAPRSHandlerThread.h" CDStarGatewayApp * CDStarGatewayApp::g_app = nullptr; @@ -197,8 +197,8 @@ bool CDStarGatewayApp::createThread() CAPRSHandler * outgoingAprsWriter = nullptr; CAPRSHandler * incomingAprsWriter = nullptr; if(aprsConfig.enabled && !aprsConfig.password.empty()) { - CAPRSHandlerThread* thread = new CAPRSHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); - outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)thread); + CAPRSISHandlerThread* aprsisthread = new CAPRSISHandlerThread(gatewayConfig.callsign, aprsConfig.password, gatewayConfig.address, aprsConfig.hostname, aprsConfig.port); + outgoingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)aprsisthread); incomingAprsWriter = new CAPRSHandler((IAPRSHandlerBackend *)new CDummyAPRSHandlerBackend()); From 364073276a7123ca49f8686c7d9c426f3c6a0365 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 18 Feb 2023 08:34:36 +0100 Subject: [PATCH 16/17] #29 Some renaming --- Common/APRSHandler.cpp | 26 +++++++++++++------------- Common/APRSHandler.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Common/APRSHandler.cpp b/Common/APRSHandler.cpp index ab84f53..e39df77 100644 --- a/Common/APRSHandler.cpp +++ b/Common/APRSHandler.cpp @@ -34,7 +34,7 @@ #include "APRSUtils.h" CAPRSHandler::CAPRSHandler(IAPRSHandlerBackend* thread) : -m_thread(thread), +m_backend(thread), m_array(), m_idFrameProvider(nullptr) { @@ -48,7 +48,7 @@ CAPRSHandler::~CAPRSHandler() } m_array.clear(); - delete m_thread; + delete m_backend; } void CAPRSHandler::setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) @@ -62,7 +62,7 @@ void CAPRSHandler::setPort(const std::string& callsign, const std::string& band, bool CAPRSHandler::open() { - return m_thread->start(); + return m_backend->start(); } void CAPRSHandler::writeHeader(const std::string& callsign, const CHeaderData& header) @@ -105,7 +105,7 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data) if (!complete) return; - if (!m_thread->isConnected()) { + if (!m_backend->isConnected()) { collector->reset(); return; } @@ -132,7 +132,7 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data) CLog::logInfo("DPRS\t%s\t%s\t%s", dstarCall.c_str(), frame.getSource().c_str(), rawFrame.c_str()); - m_thread->write(frame); + m_backend->write(frame); }); } @@ -149,7 +149,7 @@ void CAPRSHandler::writeStatus(const std::string& callsign, const std::string st void CAPRSHandler::clock(unsigned int ms) { - m_thread->clock(ms); + m_backend->clock(ms); if(m_idFrameProvider != nullptr) { m_idFrameProvider->clock(ms); @@ -171,7 +171,7 @@ void CAPRSHandler::sendStatusFrame(CAPRSEntry * entry) { assert(entry != nullptr); - if(!m_thread->isConnected()) + if(!m_backend->isConnected()) return; @@ -189,19 +189,19 @@ void CAPRSHandler::sendStatusFrame(CAPRSEntry * entry) body, APFT_STATUS); - m_thread->write(frame); + m_backend->write(frame); } void CAPRSHandler::sendIdFrames() { - if(m_thread->isConnected()) + if(m_backend->isConnected()) { for(auto entry : m_array) { std::vector frames; if(m_idFrameProvider->buildAPRSFrames(entry.second, frames)) { for(auto frame : frames) { - m_thread->write(*frame); + m_backend->write(*frame); delete frame; } } @@ -211,12 +211,12 @@ void CAPRSHandler::sendIdFrames() bool CAPRSHandler::isConnected() const { - return m_thread->isConnected(); + return m_backend->isConnected(); } void CAPRSHandler::close() { - m_thread->stop(); + m_backend->stop(); if(m_idFrameProvider != nullptr) { m_idFrameProvider->close(); @@ -227,5 +227,5 @@ void CAPRSHandler::close() void CAPRSHandler::addReadAPRSCallback(IReadAPRSFrameCallback* cb) { - m_thread->addReadAPRSCallback(cb); + m_backend->addReadAPRSCallback(cb); } diff --git a/Common/APRSHandler.h b/Common/APRSHandler.h index f4876e5..dea2046 100644 --- a/Common/APRSHandler.h +++ b/Common/APRSHandler.h @@ -61,7 +61,7 @@ public: void addReadAPRSCallback(IReadAPRSFrameCallback* cb); private: - IAPRSHandlerBackend* m_thread; + IAPRSHandlerBackend* m_backend; std::unordered_map m_array; CAPRSIdFrameProvider * m_idFrameProvider; From 1c89aa4d4ffef0617f2b9bc802c906cc29dd6ad9 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 18 Feb 2023 08:37:36 +0100 Subject: [PATCH 17/17] #29 update readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e2255d..c5c4392 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,10 @@ The testing framwework used is Google Test. # 5. Version History ## 5.1. Version 0.7 -- [**Improvement**] Add/Fix DPRS Object support([#28](https://github.com/F4FXL/DStarGateway/issues/22)) +- [**Improvement**] Add/Fix DPRS Object support([#28](https://github.com/F4FXL/DStarGateway/issues/28)) +- [**Improvement**] Log incoming DPRS frames so they can be used in e.g. dashboards([#29](https://github.com/F4FXL/DStarGateway/issues/29)) ## 5.2. Version 0.6 -- [**Improvement**] Add DRats Support ([#22](https://github.com/F4FXL/DStarGateway/issues/22)) +- [**Improvement**] Add DRats Support ([#24](https://github.com/F4FXL/DStarGateway/issues/24)) - [**Improvement**] Add call sign lists ([#22](https://github.com/F4FXL/DStarGateway/issues/22)) - [**Improvement**] Add a way to override Slow Data in VoiceTransmit ([#23](https://github.com/F4FXL/DStarGateway/issues/23)) - [**Improvement**] Add time server