diff --git a/NXDNGateway/Conf.cpp b/NXDNGateway/Conf.cpp index c1b7cd0..40fb0eb 100644 --- a/NXDNGateway/Conf.cpp +++ b/NXDNGateway/Conf.cpp @@ -65,6 +65,7 @@ m_aprsEnabled(false), m_aprsServer(), m_aprsPort(0U), m_aprsPassword(), +m_aprsSuffix(), m_aprsDescription(), m_networkPort(0U), m_networkHosts(), @@ -188,6 +189,8 @@ bool CConf::read() m_aprsPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Password") == 0) m_aprsPassword = value; + else if (::strcmp(key, "Suffix") == 0) + m_aprsSuffix = value; else if (::strcmp(key, "Description") == 0) m_aprsDescription = value; } else if (section == SECTION_NETWORK) { @@ -344,6 +347,11 @@ std::string CConf::getAPRSPassword() const return m_aprsPassword; } +std::string CConf::getAPRSSuffix() const +{ + return m_aprsSuffix; +} + std::string CConf::getAPRSDescription() const { return m_aprsDescription; diff --git a/NXDNGateway/Conf.h b/NXDNGateway/Conf.h index 4e9d44e..bfbb131 100644 --- a/NXDNGateway/Conf.h +++ b/NXDNGateway/Conf.h @@ -63,6 +63,7 @@ public: std::string getAPRSServer() const; unsigned int getAPRSPort() const; std::string getAPRSPassword() const; + std::string getAPRSSuffix() const; std::string getAPRSDescription() const; // The Log section @@ -114,6 +115,7 @@ private: std::string m_aprsServer; unsigned int m_aprsPort; std::string m_aprsPassword; + std::string m_aprsSuffix; std::string m_aprsDescription; unsigned int m_networkPort; diff --git a/NXDNGateway/GPSHandler.cpp b/NXDNGateway/GPSHandler.cpp index ef2a3ab..9a565be 100644 --- a/NXDNGateway/GPSHandler.cpp +++ b/NXDNGateway/GPSHandler.cpp @@ -29,12 +29,13 @@ const unsigned char NXDN_DATA_TYPE_GPS = 0x06U; const unsigned int NXDN_DATA_LENGTH = 20U; const unsigned int NXDN_DATA_MAX_LENGTH = 16U * NXDN_DATA_LENGTH; -CGPSHandler::CGPSHandler(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port) : +CGPSHandler::CGPSHandler(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string& suffix) : m_callsign(callsign), -m_writer(callsign, suffix, password, address, port), +m_writer(callsign, rptSuffix, password, address, port), m_data(NULL), m_length(0U), -m_source() +m_source(), +m_suffix(suffix) { assert(!callsign.empty()); assert(!password.empty()); @@ -144,16 +145,22 @@ void CGPSHandler::processNMEA() double latitude = ::atof(pRMC[3U]); double longitude = ::atof(pRMC[5U]); + std::string source = m_source; + if (!m_suffix.empty()) { + source.append("-"); + source.append(m_suffix.substr(0U, 1U)); + } + char output[300U]; if (pRMC[7U] != NULL && pRMC[8U] != NULL && ::strlen(pRMC[7U]) > 0U && ::strlen(pRMC[8U]) > 0U) { int bearing = ::atoi(pRMC[8U]); int speed = ::atoi(pRMC[7U]); - ::sprintf(output, "%s-N>APDPRS,NXDN*,qAR,%s:!%07.2lf%s/%08.2lf%sr%03d/%03d via MMDVM", - m_source.c_str(), m_callsign.c_str(), latitude, pRMC[4U], longitude, pRMC[6U], bearing, speed); + ::sprintf(output, "%s>APDPRS,NXDN*,qAR,%s:!%07.2lf%s/%08.2lf%sr%03d/%03d via MMDVM", + source.c_str(), m_callsign.c_str(), latitude, pRMC[4U], longitude, pRMC[6U], bearing, speed); } else { - ::sprintf(output, "%s-N>APDPRS,NXDN*,qAR,%s:!%07.2lf%s/%08.2lf%sr via MMDVM", - m_source.c_str(), m_callsign.c_str(), latitude, pRMC[4U], longitude, pRMC[6U]); + ::sprintf(output, "%s>APDPRS,NXDN*,qAR,%s:!%07.2lf%s/%08.2lf%sr via MMDVM", + source.c_str(), m_callsign.c_str(), latitude, pRMC[4U], longitude, pRMC[6U]); } m_writer.write(output); diff --git a/NXDNGateway/GPSHandler.h b/NXDNGateway/GPSHandler.h index e969073..23c816a 100644 --- a/NXDNGateway/GPSHandler.h +++ b/NXDNGateway/GPSHandler.h @@ -25,7 +25,7 @@ class CGPSHandler { public: - CGPSHandler(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port); + CGPSHandler(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string& suffix); ~CGPSHandler(); bool open(); @@ -48,6 +48,7 @@ private: unsigned char* m_data; unsigned int m_length; std::string m_source; + std::string m_suffix; void processNMEA(); bool checkXOR() const; diff --git a/NXDNGateway/NXDNGateway.cpp b/NXDNGateway/NXDNGateway.cpp index f3f1173..71e4722 100644 --- a/NXDNGateway/NXDNGateway.cpp +++ b/NXDNGateway/NXDNGateway.cpp @@ -482,14 +482,15 @@ void CNXDNGateway::createGPS() if (!m_conf.getAPRSEnabled()) return; - std::string callsign = m_conf.getCallsign(); - std::string suffix = m_conf.getSuffix(); - std::string hostname = m_conf.getAPRSServer(); - unsigned int port = m_conf.getAPRSPort(); - std::string password = m_conf.getAPRSPassword(); - std::string desc = m_conf.getAPRSDescription(); + std::string callsign = m_conf.getCallsign(); + std::string rptSuffix = m_conf.getSuffix(); + std::string hostname = m_conf.getAPRSServer(); + unsigned int port = m_conf.getAPRSPort(); + std::string password = m_conf.getAPRSPassword(); + std::string desc = m_conf.getAPRSDescription(); + std::string suffix = m_conf.getAPRSSuffix(); - m_gps = new CGPSHandler(callsign, suffix, password, hostname, port); + m_gps = new CGPSHandler(callsign, rptSuffix, password, hostname, port, suffix); unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/NXDNGateway/NXDNGateway.ini b/NXDNGateway/NXDNGateway.ini index 7eb5c90..93b7ea4 100644 --- a/NXDNGateway/NXDNGateway.ini +++ b/NXDNGateway/NXDNGateway.ini @@ -1,6 +1,6 @@ [General] Callsign=G4KLX -Suffix=N +Suffix=NXDN RptAddress=127.0.0.1 RptPort=14021 LocalPort=14020 @@ -29,6 +29,7 @@ Server=euro.aprs2.net Port=14580 Password=9999 Description=APRS Description +Suffix=N [Id Lookup] Name=NXDN.csv