From 3385796d221d7096207a34e15f5cd840c57a6375 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 24 May 2018 18:44:19 +0100 Subject: [PATCH] Allow for a user definable callsign suffix. --- YSFGateway/APRSWriter.cpp | 20 +++++++++++++------- YSFGateway/APRSWriter.h | 5 +++-- YSFGateway/Conf.cpp | 8 ++++++++ YSFGateway/Conf.h | 2 ++ YSFGateway/GPS.cpp | 6 +++--- YSFGateway/GPS.h | 4 ++-- YSFGateway/YSFGateway.cpp | 3 ++- YSFGateway/YSFGateway.ini | 1 + 8 files changed, 34 insertions(+), 15 deletions(-) diff --git a/YSFGateway/APRSWriter.cpp b/YSFGateway/APRSWriter.cpp index eac1077..03db91c 100644 --- a/YSFGateway/APRSWriter.cpp +++ b/YSFGateway/APRSWriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2014,2016,2017,2018 by Jonathan Naylor G4KLX * * 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 @@ -25,7 +25,7 @@ #include #include -CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port) : +CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string& suffix) : m_thread(NULL), m_enabled(false), m_idTimer(1000U, 20U * 60U), // 20 minutes @@ -35,16 +35,17 @@ m_rxFrequency(0U), m_latitude(0.0F), m_longitude(0.0F), m_height(0), -m_desc() +m_desc(), +m_suffix(suffix) { assert(!callsign.empty()); assert(!password.empty()); assert(!address.empty()); assert(port > 0U); - if (!suffix.empty()) { + if (!rptSuffix.empty()) { m_callsign.append("-"); - m_callsign.append(suffix.substr(0U, 1U)); + m_callsign.append(rptSuffix.substr(0U, 1U)); } m_thread = new CAPRSWriterThread(m_callsign, password, address, port); @@ -75,13 +76,18 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned assert(source != NULL); assert(type != NULL); - char callsign[11U]; + char callsign[15U]; ::memcpy(callsign, source, YSF_CALLSIGN_LENGTH); callsign[YSF_CALLSIGN_LENGTH] = 0x00U; size_t n = ::strspn(callsign, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); callsign[n] = 0x00U; + if (!m_suffix.empty()) { + ::strcat(callsign, "-"); + ::strcat(callsign, m_suffix.substr(0U, 1U).c_str()); + } + double tempLat = ::fabs(fLatitude); double tempLong = ::fabs(fLongitude); @@ -116,7 +122,7 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned } char output[300U]; - ::sprintf(output, "%s-Y>APDPRS,C4FM*,qAR,%s:!%s%c/%s%c%c %s via MMDVM", + ::sprintf(output, "%s>APDPRS,C4FM*,qAR,%s:!%s%c/%s%c%c %s via MMDVM", callsign, m_callsign.c_str(), lat, (fLatitude < 0.0F) ? 'S' : 'N', lon, (fLongitude < 0.0F) ? 'W' : 'E', diff --git a/YSFGateway/APRSWriter.h b/YSFGateway/APRSWriter.h index 442dd17..22e1111 100644 --- a/YSFGateway/APRSWriter.h +++ b/YSFGateway/APRSWriter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010,2011,2012,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2010,2011,2012,2016,2017,2018 by Jonathan Naylor G4KLX * * 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 @@ -26,7 +26,7 @@ class CAPRSWriter { public: - CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port); + CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string& suffix); ~CAPRSWriter(); bool open(); @@ -50,6 +50,7 @@ private: float m_longitude; int m_height; std::string m_desc; + std::string m_suffix; void sendIdFrames(); }; diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index cf00739..3cccc84 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -63,6 +63,7 @@ m_aprsEnabled(false), m_aprsServer(), m_aprsPort(0U), m_aprsPassword(), +m_aprsSuffix(), m_aprsDescription(), m_networkStartup(), m_networkInactivityTimeout(0U), @@ -189,6 +190,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) { @@ -360,6 +363,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/YSFGateway/Conf.h b/YSFGateway/Conf.h index a7310f8..0cef458 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -60,6 +60,7 @@ public: std::string getAPRSServer() const; unsigned int getAPRSPort() const; std::string getAPRSPassword() const; + std::string getAPRSSuffix() const; std::string getAPRSDescription() const; // The Network section @@ -116,6 +117,7 @@ private: std::string m_aprsServer; unsigned int m_aprsPort; std::string m_aprsPassword; + std::string m_aprsSuffix; std::string m_aprsDescription; std::string m_networkStartup; diff --git a/YSFGateway/GPS.cpp b/YSFGateway/GPS.cpp index 8d0012e..0932e25 100644 --- a/YSFGateway/GPS.cpp +++ b/YSFGateway/GPS.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * 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 @@ -31,8 +31,8 @@ const unsigned char NULL_GPS[] = {0x47U, 0x63U}; const unsigned char SHRT_GPS[] = {0x22U, 0x62U}; const unsigned char LONG_GPS[] = {0x47U, 0x64U}; -CGPS::CGPS(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port) : -m_writer(callsign, suffix, password, address, port), +CGPS::CGPS(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string suffix) : +m_writer(callsign, rptSuffix, password, address, port, suffix), m_buffer(NULL), m_sent(false) { diff --git a/YSFGateway/GPS.h b/YSFGateway/GPS.h index f168dfd..3a163f4 100644 --- a/YSFGateway/GPS.h +++ b/YSFGateway/GPS.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX * * 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 @@ -25,7 +25,7 @@ class CGPS { public: - CGPS(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port); + CGPS(const std::string& callsign, const std::string& rptSuffix, const std::string& password, const std::string& address, unsigned int port, const std::string suffix); ~CGPS(); void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index a4d22d0..cb47ddf 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -425,9 +425,10 @@ void CYSFGateway::createGPS() std::string hostname = m_conf.getAPRSServer(); unsigned int port = m_conf.getAPRSPort(); std::string password = m_conf.getAPRSPassword(); + std::string suffix = m_conf.getAPRSSuffix(); std::string desc = m_conf.getAPRSDescription(); - m_gps = new CGPS(m_callsign, m_suffix, password, hostname, port); + m_gps = new CGPS(m_callsign, m_suffix, password, hostname, port, suffix); unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 977ba17..acb6a67 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -33,6 +33,7 @@ Server=euro.aprs2.net Port=14580 Password=9999 Description=APRS Description +Suffix=Y [Network] # Startup=FCS00120