diff --git a/YSFGateway/APRSWriter.cpp b/YSFGateway/APRSWriter.cpp index b29275c..a9b489d 100644 --- a/YSFGateway/APRSWriter.cpp +++ b/YSFGateway/APRSWriter.cpp @@ -25,11 +25,12 @@ #include #include -CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& password, const std::string& address, unsigned int port) : +CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port) : m_thread(NULL), m_enabled(false), m_idTimer(1000U, 20U * 60U), // 20 minutes -m_callsign(), +m_callsign(callsign), +m_suffix(suffix), m_txFrequency(0U), m_rxFrequency(0U), m_latitude(0.0F), @@ -255,8 +256,9 @@ void CAPRSWriter::sendIdFrames() *p = '.'; char output[500U]; - ::sprintf(output, "%s-S>APDG03,TCPIP*,qAC,%s-NDS:;%-7s%-2s*%02d%02d%02dz%s%cD%s%ca/A=%06.0f%s %s", - m_callsign.c_str(), m_callsign.c_str(), m_callsign.c_str(), m_band.c_str(), + ::sprintf(output, "%s-S>APDG03,TCPIP*,qAC,%s-%sS:;%-7s%-2s*%02d%02d%02dz%s%cD%s%ca/A=%06.0f%s %s", + m_callsign.c_str(), m_callsign.c_str(), m_suffix.c_str(), + m_callsign.c_str(), m_band.c_str(), tm->tm_mday, tm->tm_hour, tm->tm_min, lat, (m_latitude < 0.0F) ? 'S' : 'N', lon, (m_longitude < 0.0F) ? 'W' : 'E', diff --git a/YSFGateway/APRSWriter.h b/YSFGateway/APRSWriter.h index 59bfaf2..1bccee4 100644 --- a/YSFGateway/APRSWriter.h +++ b/YSFGateway/APRSWriter.h @@ -26,7 +26,7 @@ class CAPRSWriter { public: - CAPRSWriter(const std::string& callsign, const std::string& password, const std::string& address, unsigned int port); + CAPRSWriter(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port); ~CAPRSWriter(); bool open(); @@ -44,6 +44,7 @@ private: bool m_enabled; CTimer m_idTimer; std::string m_callsign; + std::string m_suffix; unsigned int m_txFrequency; unsigned int m_rxFrequency; float m_latitude; diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index ffcf328..e148706 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -38,6 +38,7 @@ enum SECTION { CConf::CConf(const std::string& file) : m_file(file), m_callsign(), +m_suffix(), m_rptAddress(), m_rptPort(0U), m_myAddress(), @@ -114,6 +115,11 @@ bool CConf::read() for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); m_callsign = value; + } else if (::strcmp(key, "Suffix") == 0) { + // Convert the callsign to upper case + for (unsigned int i = 0U; value[i] != 0; i++) + value[i] = ::toupper(value[i]); + m_suffix = value; } else if (::strcmp(key, "RptAddress") == 0) m_rptAddress = value; else if (::strcmp(key, "RptPort") == 0) @@ -183,6 +189,11 @@ std::string CConf::getCallsign() const return m_callsign; } +std::string CConf::getSuffix() const +{ + return m_suffix; +} + std::string CConf::getRptAddress() const { return m_rptAddress; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 5ece00a..7dc0963 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -32,6 +32,7 @@ public: // The General section std::string getCallsign() const; + std::string getSuffix() const; std::string getRptAddress() const; unsigned int getRptPort() const; std::string getMyAddress() const; @@ -70,6 +71,7 @@ public: private: std::string m_file; std::string m_callsign; + std::string m_suffix; std::string m_rptAddress; unsigned int m_rptPort; std::string m_myAddress; diff --git a/YSFGateway/GPS.cpp b/YSFGateway/GPS.cpp index 8f90357..ec82153 100644 --- a/YSFGateway/GPS.cpp +++ b/YSFGateway/GPS.cpp @@ -30,8 +30,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& password, const std::string& address, unsigned int port) : -m_writer(callsign, password, address, port), +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), m_buffer(NULL), m_dt1(false), m_dt2(false), diff --git a/YSFGateway/GPS.h b/YSFGateway/GPS.h index cabb4fa..968b61f 100644 --- a/YSFGateway/GPS.h +++ b/YSFGateway/GPS.h @@ -25,7 +25,7 @@ class CGPS { public: - CGPS(const std::string& callsign, const std::string& password, const std::string& address, unsigned int port); + CGPS(const std::string& callsign, const std::string& suffix, const std::string& password, const std::string& address, unsigned int port); ~CGPS(); void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height); diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 82907e8..b1b0aa2 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -42,7 +42,7 @@ const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U}; const unsigned char NET_HEADER[] = "YSFDGATEWAY ALL "; -CWiresX::CWiresX(const std::string& callsign, CNetwork* network, const std::string& hostsFile, unsigned int statusPort) : +CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int statusPort) : m_callsign(callsign), m_node(), m_network(network), @@ -68,7 +68,10 @@ m_search(NULL) assert(statusPort > 0U); m_node = callsign; - m_node.append("-ND"); + if (suffix.size() > 0U) { + m_node.append("-"); + m_node.append(suffix); + } m_node.resize(YSF_CALLSIGN_LENGTH, ' '); m_callsign.resize(YSF_CALLSIGN_LENGTH, ' '); diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index aacd16a..e5b890f 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -43,7 +43,7 @@ enum WXSI_STATUS { class CWiresX { public: - CWiresX(const std::string& callsign, CNetwork* network, const std::string& hostsFile, unsigned int statusPort); + CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int statusPort); ~CWiresX(); void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index df111d7..3882e93 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -75,6 +75,7 @@ int main(int argc, char** argv) CYSFGateway::CYSFGateway(const std::string& configFile) : m_callsign(), +m_suffix(), m_conf(configFile), m_gps(NULL), m_wiresX(NULL), @@ -161,6 +162,7 @@ int CYSFGateway::run() #endif m_callsign = m_conf.getCallsign(); + m_suffix = m_conf.getSuffix(); bool debug = m_conf.getNetworkDebug(); in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress()); @@ -191,7 +193,7 @@ int CYSFGateway::run() std::string fileName = m_conf.getNetworkHosts(); unsigned int port = m_conf.getNetworkStatusPort(); - m_wiresX = new CWiresX(m_callsign, &rptNetwork, fileName, port); + m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, port); std::string name = m_conf.getName(); unsigned int txFrequency = m_conf.getTxFrequency(); @@ -315,7 +317,7 @@ void CYSFGateway::createGPS() unsigned int port = m_conf.getAPRSPort(); std::string password = m_conf.getAPRSPassword(); - m_gps = new CGPS(m_callsign, password, hostname, port); + m_gps = new CGPS(m_callsign, m_suffix, password, hostname, port); unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index f1ce074..9c3f413 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -36,6 +36,7 @@ public: private: std::string m_callsign; + std::string m_suffix; CConf m_conf; CGPS* m_gps; CWiresX* m_wiresX; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index e26e7dd..03fa894 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -1,5 +1,7 @@ [General] Callsign=G9BF +Suffix=RPT +# Suffix=ND RptAddress=127.0.0.1 RptPort=3200 LocalAddress=127.0.0.1