1
0
Fork 0

Allow for a user definable callsign suffix.

ycs232-kbc
Jonathan Naylor 6 years ago
parent 11cad79a95
commit 3385796d22

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
#include <cstring> #include <cstring>
#include <cmath> #include <cmath>
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_thread(NULL),
m_enabled(false), m_enabled(false),
m_idTimer(1000U, 20U * 60U), // 20 minutes m_idTimer(1000U, 20U * 60U), // 20 minutes
@ -35,16 +35,17 @@ m_rxFrequency(0U),
m_latitude(0.0F), m_latitude(0.0F),
m_longitude(0.0F), m_longitude(0.0F),
m_height(0), m_height(0),
m_desc() m_desc(),
m_suffix(suffix)
{ {
assert(!callsign.empty()); assert(!callsign.empty());
assert(!password.empty()); assert(!password.empty());
assert(!address.empty()); assert(!address.empty());
assert(port > 0U); assert(port > 0U);
if (!suffix.empty()) { if (!rptSuffix.empty()) {
m_callsign.append("-"); 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); 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(source != NULL);
assert(type != NULL); assert(type != NULL);
char callsign[11U]; char callsign[15U];
::memcpy(callsign, source, YSF_CALLSIGN_LENGTH); ::memcpy(callsign, source, YSF_CALLSIGN_LENGTH);
callsign[YSF_CALLSIGN_LENGTH] = 0x00U; callsign[YSF_CALLSIGN_LENGTH] = 0x00U;
size_t n = ::strspn(callsign, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); size_t n = ::strspn(callsign, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
callsign[n] = 0x00U; callsign[n] = 0x00U;
if (!m_suffix.empty()) {
::strcat(callsign, "-");
::strcat(callsign, m_suffix.substr(0U, 1U).c_str());
}
double tempLat = ::fabs(fLatitude); double tempLat = ::fabs(fLatitude);
double tempLong = ::fabs(fLongitude); double tempLong = ::fabs(fLongitude);
@ -116,7 +122,7 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned
} }
char output[300U]; 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(), callsign, m_callsign.c_str(),
lat, (fLatitude < 0.0F) ? 'S' : 'N', lat, (fLatitude < 0.0F) ? 'S' : 'N',
lon, (fLongitude < 0.0F) ? 'W' : 'E', lon, (fLongitude < 0.0F) ? 'W' : 'E',

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@
class CAPRSWriter { class CAPRSWriter {
public: 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(); ~CAPRSWriter();
bool open(); bool open();
@ -50,6 +50,7 @@ private:
float m_longitude; float m_longitude;
int m_height; int m_height;
std::string m_desc; std::string m_desc;
std::string m_suffix;
void sendIdFrames(); void sendIdFrames();
}; };

@ -63,6 +63,7 @@ m_aprsEnabled(false),
m_aprsServer(), m_aprsServer(),
m_aprsPort(0U), m_aprsPort(0U),
m_aprsPassword(), m_aprsPassword(),
m_aprsSuffix(),
m_aprsDescription(), m_aprsDescription(),
m_networkStartup(), m_networkStartup(),
m_networkInactivityTimeout(0U), m_networkInactivityTimeout(0U),
@ -189,6 +190,8 @@ bool CConf::read()
m_aprsPort = (unsigned int)::atoi(value); m_aprsPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Password") == 0) else if (::strcmp(key, "Password") == 0)
m_aprsPassword = value; m_aprsPassword = value;
else if (::strcmp(key, "Suffix") == 0)
m_aprsSuffix = value;
else if (::strcmp(key, "Description") == 0) else if (::strcmp(key, "Description") == 0)
m_aprsDescription = value; m_aprsDescription = value;
} else if (section == SECTION_NETWORK) { } else if (section == SECTION_NETWORK) {
@ -360,6 +363,11 @@ std::string CConf::getAPRSPassword() const
return m_aprsPassword; return m_aprsPassword;
} }
std::string CConf::getAPRSSuffix() const
{
return m_aprsSuffix;
}
std::string CConf::getAPRSDescription() const std::string CConf::getAPRSDescription() const
{ {
return m_aprsDescription; return m_aprsDescription;

@ -60,6 +60,7 @@ public:
std::string getAPRSServer() const; std::string getAPRSServer() const;
unsigned int getAPRSPort() const; unsigned int getAPRSPort() const;
std::string getAPRSPassword() const; std::string getAPRSPassword() const;
std::string getAPRSSuffix() const;
std::string getAPRSDescription() const; std::string getAPRSDescription() const;
// The Network section // The Network section
@ -116,6 +117,7 @@ private:
std::string m_aprsServer; std::string m_aprsServer;
unsigned int m_aprsPort; unsigned int m_aprsPort;
std::string m_aprsPassword; std::string m_aprsPassword;
std::string m_aprsSuffix;
std::string m_aprsDescription; std::string m_aprsDescription;
std::string m_networkStartup; std::string m_networkStartup;

@ -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 * 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 * 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 SHRT_GPS[] = {0x22U, 0x62U};
const unsigned char LONG_GPS[] = {0x47U, 0x64U}; 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) : 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, suffix, password, address, port), m_writer(callsign, rptSuffix, password, address, port, suffix),
m_buffer(NULL), m_buffer(NULL),
m_sent(false) m_sent(false)
{ {

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
class CGPS { class CGPS {
public: 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(); ~CGPS();
void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc); void setInfo(unsigned int txFrequency, unsigned int rxFrequency, float latitude, float longitude, int height, const std::string& desc);

@ -425,9 +425,10 @@ void CYSFGateway::createGPS()
std::string hostname = m_conf.getAPRSServer(); std::string hostname = m_conf.getAPRSServer();
unsigned int port = m_conf.getAPRSPort(); unsigned int port = m_conf.getAPRSPort();
std::string password = m_conf.getAPRSPassword(); std::string password = m_conf.getAPRSPassword();
std::string suffix = m_conf.getAPRSSuffix();
std::string desc = m_conf.getAPRSDescription(); 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 txFrequency = m_conf.getTxFrequency();
unsigned int rxFrequency = m_conf.getRxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency();

@ -33,6 +33,7 @@ Server=euro.aprs2.net
Port=14580 Port=14580
Password=9999 Password=9999
Description=APRS Description Description=APRS Description
Suffix=Y
[Network] [Network]
# Startup=FCS00120 # Startup=FCS00120

Loading…
Cancel
Save