1
0
Fork 0

Add a configurable suffix.

ycs232-kbc
Jonathan Naylor 9 years ago
parent 1d9a6dc16c
commit 340eab64a6

@ -25,11 +25,12 @@
#include <cstring>
#include <ctime>
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',

@ -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;

@ -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;

@ -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;

@ -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),

@ -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);

@ -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, ' ');

@ -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);

@ -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();

@ -36,6 +36,7 @@ public:
private:
std::string m_callsign;
std::string m_suffix;
CConf m_conf;
CGPS* m_gps;
CWiresX* m_wiresX;

@ -1,5 +1,7 @@
[General]
Callsign=G9BF
Suffix=RPT
# Suffix=ND
RptAddress=127.0.0.1
RptPort=3200
LocalAddress=127.0.0.1

Loading…
Cancel
Save