From 508692a5546724c50140726d2c8b705752d8d8a1 Mon Sep 17 00:00:00 2001 From: Chipster Date: Sun, 12 Feb 2023 19:27:45 -0600 Subject: [PATCH 1/2] Add `Symbol=` option to `[APRS]` stanza in config, to allow user to define APRS symbol. Backward-compat., and will default to the standard `D&` symbol (diamond with "D" overlay) if `Symbol=` is not defined. --- APRSWriter.cpp | 15 +++++++++++---- APRSWriter.h | 3 ++- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ DMRGateway.cpp | 3 ++- Version.h | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/APRSWriter.cpp b/APRSWriter.cpp index f5fa837..99db6fa 100644 --- a/APRSWriter.cpp +++ b/APRSWriter.cpp @@ -35,6 +35,7 @@ m_latitude(0.0F), m_longitude(0.0F), m_height(0), m_desc(), +m_symbol(), m_aprsAddr(), m_aprsLen(0U), m_aprsSocket() @@ -56,11 +57,13 @@ CAPRSWriter::~CAPRSWriter() { } -void CAPRSWriter::setInfo(unsigned int txFrequency, unsigned int rxFrequency, const std::string& desc) +void CAPRSWriter::setInfo(unsigned int txFrequency, unsigned int rxFrequency, const std::string& desc, const std::string& symbol) + { m_txFrequency = txFrequency; m_rxFrequency = rxFrequency; m_desc = desc; + m_symbol = symbol; } void CAPRSWriter::setLocation(float latitude, float longitude, int height) @@ -149,17 +152,21 @@ void CAPRSWriter::sendIdFrame() ::sprintf(lon, "%08.2lf", longitude); std::string server = m_callsign; + std::string symbol = m_symbol; size_t pos = server.find_first_of('-'); if (pos == std::string::npos) server.append("-S"); else server.append("S"); + if (symbol.empty()) + symbol.append("D&"); + char output[500U]; - ::sprintf(output, "%s>APDG03,TCPIP*,qAC,%s:!%s%cD%s%c&/A=%06.0f%s %s\r\n", + ::sprintf(output, "%s>APDG03,TCPIP*,qAC,%s:!%s%c%c%s%c%c/A=%06.0f%s %s\r\n", m_callsign.c_str(), server.c_str(), - lat, (m_latitude < 0.0F) ? 'S' : 'N', - lon, (m_longitude < 0.0F) ? 'W' : 'E', + lat, (m_latitude < 0.0F) ? 'S' : 'N', symbol[0], + lon, (m_longitude < 0.0F) ? 'W' : 'E', symbol[1], float(m_height) * 3.28F, band, desc); if (m_debug) diff --git a/APRSWriter.h b/APRSWriter.h index 0043676..164e571 100644 --- a/APRSWriter.h +++ b/APRSWriter.h @@ -44,7 +44,7 @@ public: bool open(); - void setInfo(unsigned int txFrequency, unsigned int rxFrequency, const std::string& desc); + void setInfo(unsigned int txFrequency, unsigned int rxFrequency, const std::string& desc, const std::string& symbol); void setLocation(float latitude, float longitude, int height); @@ -62,6 +62,7 @@ private: float m_longitude; int m_height; std::string m_desc; + std::string m_symbol; sockaddr_storage m_aprsAddr; unsigned int m_aprsLen; CUDPSocket m_aprsSocket; diff --git a/Conf.cpp b/Conf.cpp index 5bb71e8..ef3550f 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -182,6 +182,7 @@ m_aprsAddress(), m_aprsPort(0U), m_aprsSuffix(), m_aprsDescription(), +m_aprsSymbol(), m_dynamicTGControlEnabled(false), m_dynamicTGControlPort(3769U), m_remoteControlEnabled(false), @@ -989,6 +990,8 @@ bool CConf::read() m_aprsSuffix = value; else if (::strcmp(key, "Description") == 0) m_aprsDescription = value; + else if (::strcmp(key, "Symbol") == 0) + m_aprsSymbol = value; } else if (section == SECTION_DYNAMIC_TG_CONTROL) { if (::strcmp(key, "Enabled") == 0) m_dynamicTGControlEnabled = ::atoi(value) == 1; @@ -1702,6 +1705,11 @@ std::string CConf::getAPRSDescription() const return m_aprsDescription; } +std::string CConf::getAPRSSymbol() const +{ + return m_aprsSymbol; +} + bool CConf::getDynamicTGControlEnabled() const { return m_dynamicTGControlEnabled; diff --git a/Conf.h b/Conf.h index 388fe4b..40a9c9e 100644 --- a/Conf.h +++ b/Conf.h @@ -236,6 +236,7 @@ public: unsigned short getAPRSPort() const; std::string getAPRSSuffix() const; std::string getAPRSDescription() const; + std::string getAPRSSymbol() const; // The Dynamic TG Control section bool getDynamicTGControlEnabled() const; @@ -395,6 +396,7 @@ private: unsigned short m_aprsPort; std::string m_aprsSuffix; std::string m_aprsDescription; + std::string m_aprsSymbol; bool m_dynamicTGControlEnabled; unsigned short m_dynamicTGControlPort; diff --git a/DMRGateway.cpp b/DMRGateway.cpp index c516c98..701ad82 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -2528,8 +2528,9 @@ void CDMRGateway::createAPRS() m_writer = new CAPRSWriter(m_callsign, suffix, address, port, debug); std::string desc = m_conf.getAPRSDescription(); + std::string symbol = m_conf.getAPRSSymbol(); - m_writer->setInfo(m_txFrequency, m_rxFrequency, desc); + m_writer->setInfo(m_txFrequency, m_rxFrequency, desc, symbol); float latitude = m_conf.getInfoLatitude(); float longitude = m_conf.getInfoLongitude(); diff --git a/Version.h b/Version.h index 1a43e3a..44e8fb3 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210409"; +const char* VERSION = "20230212"; #endif From 32e4282de7d4c6144efbd2fdeda97ec4c9099c4d Mon Sep 17 00:00:00 2001 From: Chipster Date: Mon, 13 Feb 2023 06:09:51 -0600 Subject: [PATCH 2/2] Update INI with new `Symbol` config item --- DMRGateway.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/DMRGateway.ini b/DMRGateway.ini index 2431434..1699fd8 100644 --- a/DMRGateway.ini +++ b/DMRGateway.ini @@ -149,6 +149,7 @@ Address=127.0.0.1 Port=8673 Description=APRS Description Suffix=3 +# Symbol=/r [Dynamic TG Control] Enabled=1