From 2f41b0eaabc2e6bf7dad016ff454401bbea530bf Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 3 Sep 2017 22:26:13 +0100 Subject: [PATCH] Add the desciption field to the APRS data for this node/repeater. --- YSFGateway/APRSWriter.cpp | 16 +++++++++------- YSFGateway/APRSWriter.h | 5 +++-- YSFGateway/GPS.cpp | 6 +++--- YSFGateway/GPS.h | 4 ++-- YSFGateway/YSFGateway.cpp | 3 ++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/YSFGateway/APRSWriter.cpp b/YSFGateway/APRSWriter.cpp index 2a771a7..eac1077 100644 --- a/YSFGateway/APRSWriter.cpp +++ b/YSFGateway/APRSWriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2014,2016,2017 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 @@ -34,7 +34,8 @@ m_txFrequency(0U), m_rxFrequency(0U), m_latitude(0.0F), m_longitude(0.0F), -m_height(0) +m_height(0), +m_desc() { assert(!callsign.empty()); assert(!password.empty()); @@ -53,13 +54,14 @@ CAPRSWriter::~CAPRSWriter() { } -void CAPRSWriter::setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height) +void CAPRSWriter::setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc) { m_txFrequency = txFrequency; m_rxFrequency = rxFrequency; m_latitude = latitude; m_longitude = longitude; m_height = height; + m_desc = desc; } bool CAPRSWriter::open() @@ -147,15 +149,15 @@ void CAPRSWriter::sendIdFrames() if (m_latitude == 0.0F && m_longitude == 0.0F) return; - char desc[100U]; + char desc[200U]; if (m_txFrequency != 0U) { float offset = float(int(m_rxFrequency) - int(m_txFrequency)) / 1000000.0F; - ::sprintf(desc, "MMDVM Voice %.5LfMHz %c%.4lfMHz", + ::sprintf(desc, "MMDVM Voice %.5LfMHz %c%.4lfMHz%s%s", (long double)(m_txFrequency) / 1000000.0F, offset < 0.0F ? '-' : '+', - ::fabs(offset)); + ::fabs(offset), m_desc.empty() ? "" : ", ", m_desc.c_str()); } else { - ::strcpy(desc, "MMDVM Voice"); + ::sprintf(desc, "MMDVM Voice%s%s", m_desc.empty() ? "" : ", ", m_desc.c_str()); } const char* band = "4m"; diff --git a/YSFGateway/APRSWriter.h b/YSFGateway/APRSWriter.h index 4095bc5..442dd17 100644 --- a/YSFGateway/APRSWriter.h +++ b/YSFGateway/APRSWriter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010,2011,2012,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2010,2011,2012,2016,2017 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,7 +31,7 @@ public: bool open(); - void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height); + void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc); void write(const unsigned char* source, const char* type, unsigned char radio, float latitude, float longitude); @@ -49,6 +49,7 @@ private: float m_latitude; float m_longitude; int m_height; + std::string m_desc; void sendIdFrames(); }; diff --git a/YSFGateway/GPS.cpp b/YSFGateway/GPS.cpp index c3a1651..0d12bb0 100644 --- a/YSFGateway/GPS.cpp +++ b/YSFGateway/GPS.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017 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 @@ -49,9 +49,9 @@ CGPS::~CGPS() delete[] m_buffer; } -void CGPS::setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height) +void CGPS::setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc) { - m_writer.setInfo(txFrequency, rxFrequency, latitude, longitude, height); + m_writer.setInfo(txFrequency, rxFrequency, latitude, longitude, height, desc); } bool CGPS::open() diff --git a/YSFGateway/GPS.h b/YSFGateway/GPS.h index 379f3b7..f168dfd 100644 --- a/YSFGateway/GPS.h +++ b/YSFGateway/GPS.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017 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 @@ -28,7 +28,7 @@ public: 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); + void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc); bool open(); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index e063082..80d388c 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -509,8 +509,9 @@ void CYSFGateway::createGPS() float latitude = m_conf.getLatitude(); float longitude = m_conf.getLongitude(); int height = m_conf.getHeight(); + std::string desc = m_conf.getDescription(); - m_gps->setInfo(txFrequency, rxFrequency, latitude, longitude, height); + m_gps->setInfo(txFrequency, rxFrequency, latitude, longitude, height, desc); bool ret = m_gps->open(); if (!ret) {