Begin adding FCS specific code.
This commit is contained in:
parent
c84df3db5e
commit
05c0cce1db
12 changed files with 420 additions and 108 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,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
|
||||
|
@ -32,7 +32,8 @@ enum SECTION {
|
|||
SECTION_INFO,
|
||||
SECTION_LOG,
|
||||
SECTION_APRS_FI,
|
||||
SECTION_NETWORK
|
||||
SECTION_YSF_NETWORK,
|
||||
SECTION_FCS_NETWORK
|
||||
};
|
||||
|
||||
CConf::CConf(const std::string& file) :
|
||||
|
@ -61,18 +62,21 @@ m_aprsServer(),
|
|||
m_aprsPort(0U),
|
||||
m_aprsPassword(),
|
||||
m_aprsDescription(),
|
||||
m_networkEnabled(false),
|
||||
m_networkPort(0U),
|
||||
m_networkHosts(),
|
||||
m_networkReloadTime(0U),
|
||||
m_networkParrotAddress("127.0.0.1"),
|
||||
m_networkParrotPort(0U),
|
||||
m_networkYSF2DMRAddress("127.0.0.1"),
|
||||
m_networkYSF2DMRPort(0U),
|
||||
m_networkStartup(),
|
||||
m_networkInactivityTimeout(0U),
|
||||
m_networkRevert(false),
|
||||
m_networkDebug(false)
|
||||
m_ysfNetworkEnabled(false),
|
||||
m_ysfNetworkPort(0U),
|
||||
m_ysfNetworkHosts(),
|
||||
m_ysfNetworkReloadTime(0U),
|
||||
m_ysfNetworkParrotAddress("127.0.0.1"),
|
||||
m_ysfNetworkParrotPort(0U),
|
||||
m_ysfNetworkYSF2DMRAddress("127.0.0.1"),
|
||||
m_ysfNetworkYSF2DMRPort(0U),
|
||||
m_ysfNetworkStartup(),
|
||||
m_ysfNetworkInactivityTimeout(0U),
|
||||
m_ysfNetworkRevert(false),
|
||||
m_ysfNetworkDebug(false),
|
||||
m_fcsNetworkEnabled(false),
|
||||
m_fcsNetworkPort(0U),
|
||||
m_fcsNetworkDebug(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -102,10 +106,12 @@ bool CConf::read()
|
|||
section = SECTION_INFO;
|
||||
else if (::strncmp(buffer, "[Log]", 5U) == 0)
|
||||
section = SECTION_LOG;
|
||||
else if (::strncmp(buffer, "[aprs.fi]", 5U) == 0)
|
||||
else if (::strncmp(buffer, "[aprs.fi]", 9U) == 0)
|
||||
section = SECTION_APRS_FI;
|
||||
else if (::strncmp(buffer, "[Network]", 5U) == 0)
|
||||
section = SECTION_NETWORK;
|
||||
else if (::strncmp(buffer, "[YSF Network]", 13U) == 0)
|
||||
section = SECTION_YSF_NETWORK;
|
||||
else if (::strncmp(buffer, "[FCS Network]", 13U) == 0)
|
||||
section = SECTION_FCS_NETWORK;
|
||||
else
|
||||
section = SECTION_NONE;
|
||||
|
||||
|
@ -175,31 +181,38 @@ bool CConf::read()
|
|||
m_aprsPassword = value;
|
||||
else if (::strcmp(key, "Description") == 0)
|
||||
m_aprsDescription = value;
|
||||
} else if (section == SECTION_NETWORK) {
|
||||
} else if (section == SECTION_YSF_NETWORK) {
|
||||
if (::strcmp(key, "Enable") == 0)
|
||||
m_networkEnabled = ::atoi(value) == 1;
|
||||
m_ysfNetworkEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_networkPort = (unsigned int)::atoi(value);
|
||||
m_ysfNetworkPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Hosts") == 0)
|
||||
m_networkHosts = value;
|
||||
m_ysfNetworkHosts = value;
|
||||
else if (::strcmp(key, "ReloadTime") == 0)
|
||||
m_networkReloadTime = (unsigned int)::atoi(value);
|
||||
m_ysfNetworkReloadTime = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "ParrotAddress") == 0)
|
||||
m_networkParrotAddress = value;
|
||||
m_ysfNetworkParrotAddress = value;
|
||||
else if (::strcmp(key, "ParrotPort") == 0)
|
||||
m_networkParrotPort = (unsigned int)::atoi(value);
|
||||
m_ysfNetworkParrotPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "YSF2DMRAddress") == 0)
|
||||
m_networkYSF2DMRAddress = value;
|
||||
m_ysfNetworkYSF2DMRAddress = value;
|
||||
else if (::strcmp(key, "YSF2DMRPort") == 0)
|
||||
m_networkYSF2DMRPort = (unsigned int)::atoi(value);
|
||||
m_ysfNetworkYSF2DMRPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Startup") == 0)
|
||||
m_networkStartup = value;
|
||||
m_ysfNetworkStartup = value;
|
||||
else if (::strcmp(key, "InactivityTimeout") == 0)
|
||||
m_networkInactivityTimeout = (unsigned int)::atoi(value);
|
||||
m_ysfNetworkInactivityTimeout = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Revert") == 0)
|
||||
m_networkRevert = ::atoi(value) == 1;
|
||||
m_ysfNetworkRevert = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_networkDebug = ::atoi(value) == 1;
|
||||
m_ysfNetworkDebug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_FCS_NETWORK) {
|
||||
if (::strcmp(key, "Enable") == 0)
|
||||
m_fcsNetworkEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_fcsNetworkPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_fcsNetworkDebug = ::atoi(value) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,62 +341,77 @@ std::string CConf::getAPRSDescription() const
|
|||
return m_aprsDescription;
|
||||
}
|
||||
|
||||
bool CConf::getNetworkEnabled() const
|
||||
bool CConf::getYSFNetworkEnabled() const
|
||||
{
|
||||
return m_networkEnabled;
|
||||
return m_ysfNetworkEnabled;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkPort() const
|
||||
unsigned int CConf::getYSFNetworkPort() const
|
||||
{
|
||||
return m_networkPort;
|
||||
return m_ysfNetworkPort;
|
||||
}
|
||||
|
||||
std::string CConf::getNetworkHosts() const
|
||||
std::string CConf::getYSFNetworkHosts() const
|
||||
{
|
||||
return m_networkHosts;
|
||||
return m_ysfNetworkHosts;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkReloadTime() const
|
||||
unsigned int CConf::getYSFNetworkReloadTime() const
|
||||
{
|
||||
return m_networkReloadTime;
|
||||
return m_ysfNetworkReloadTime;
|
||||
}
|
||||
|
||||
std::string CConf::getNetworkParrotAddress() const
|
||||
std::string CConf::getYSFNetworkParrotAddress() const
|
||||
{
|
||||
return m_networkParrotAddress;
|
||||
return m_ysfNetworkParrotAddress;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkParrotPort() const
|
||||
unsigned int CConf::getYSFNetworkParrotPort() const
|
||||
{
|
||||
return m_networkParrotPort;
|
||||
return m_ysfNetworkParrotPort;
|
||||
}
|
||||
|
||||
std::string CConf::getNetworkYSF2DMRAddress() const
|
||||
std::string CConf::getYSFNetworkYSF2DMRAddress() const
|
||||
{
|
||||
return m_networkYSF2DMRAddress;
|
||||
return m_ysfNetworkYSF2DMRAddress;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkYSF2DMRPort() const
|
||||
unsigned int CConf::getYSFNetworkYSF2DMRPort() const
|
||||
{
|
||||
return m_networkYSF2DMRPort;
|
||||
return m_ysfNetworkYSF2DMRPort;
|
||||
}
|
||||
|
||||
std::string CConf::getNetworkStartup() const
|
||||
std::string CConf::getYSFNetworkStartup() const
|
||||
{
|
||||
return m_networkStartup;
|
||||
return m_ysfNetworkStartup;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkInactivityTimeout() const
|
||||
unsigned int CConf::getYSFNetworkInactivityTimeout() const
|
||||
{
|
||||
return m_networkInactivityTimeout;
|
||||
return m_ysfNetworkInactivityTimeout;
|
||||
}
|
||||
|
||||
bool CConf::getNetworkRevert() const
|
||||
bool CConf::getYSFNetworkRevert() const
|
||||
{
|
||||
return m_networkRevert;
|
||||
return m_ysfNetworkRevert;
|
||||
}
|
||||
|
||||
bool CConf::getNetworkDebug() const
|
||||
bool CConf::getYSFNetworkDebug() const
|
||||
{
|
||||
return m_networkDebug;
|
||||
return m_ysfNetworkDebug;
|
||||
}
|
||||
|
||||
bool CConf::getFCSNetworkEnabled() const
|
||||
{
|
||||
return m_fcsNetworkEnabled;
|
||||
}
|
||||
|
||||
unsigned int CConf::getFCSNetworkPort() const
|
||||
{
|
||||
return m_fcsNetworkPort;
|
||||
}
|
||||
|
||||
bool CConf::getFCSNetworkDebug() const
|
||||
{
|
||||
return m_fcsNetworkDebug;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,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
|
||||
|
@ -62,19 +62,24 @@ public:
|
|||
std::string getAPRSPassword() const;
|
||||
std::string getAPRSDescription() const;
|
||||
|
||||
// The Network section
|
||||
bool getNetworkEnabled() const;
|
||||
unsigned int getNetworkPort() const;
|
||||
std::string getNetworkHosts() const;
|
||||
unsigned int getNetworkReloadTime() const;
|
||||
std::string getNetworkParrotAddress() const;
|
||||
unsigned int getNetworkParrotPort() const;
|
||||
std::string getNetworkYSF2DMRAddress() const;
|
||||
unsigned int getNetworkYSF2DMRPort() const;
|
||||
std::string getNetworkStartup() const;
|
||||
unsigned int getNetworkInactivityTimeout() const;
|
||||
bool getNetworkRevert() const;
|
||||
bool getNetworkDebug() const;
|
||||
// The YSF Network section
|
||||
bool getYSFNetworkEnabled() const;
|
||||
unsigned int getYSFNetworkPort() const;
|
||||
std::string getYSFNetworkHosts() const;
|
||||
unsigned int getYSFNetworkReloadTime() const;
|
||||
std::string getYSFNetworkParrotAddress() const;
|
||||
unsigned int getYSFNetworkParrotPort() const;
|
||||
std::string getYSFNetworkYSF2DMRAddress() const;
|
||||
unsigned int getYSFNetworkYSF2DMRPort() const;
|
||||
std::string getYSFNetworkStartup() const;
|
||||
unsigned int getYSFNetworkInactivityTimeout() const;
|
||||
bool getYSFNetworkRevert() const;
|
||||
bool getYSFNetworkDebug() const;
|
||||
|
||||
// The FCS Network section
|
||||
bool getFCSNetworkEnabled() const;
|
||||
unsigned int getFCSNetworkPort() const;
|
||||
bool getFCSNetworkDebug() const;
|
||||
|
||||
private:
|
||||
std::string m_file;
|
||||
|
@ -106,18 +111,22 @@ private:
|
|||
std::string m_aprsPassword;
|
||||
std::string m_aprsDescription;
|
||||
|
||||
bool m_networkEnabled;
|
||||
unsigned int m_networkPort;
|
||||
std::string m_networkHosts;
|
||||
unsigned int m_networkReloadTime;
|
||||
std::string m_networkParrotAddress;
|
||||
unsigned int m_networkParrotPort;
|
||||
std::string m_networkYSF2DMRAddress;
|
||||
unsigned int m_networkYSF2DMRPort;
|
||||
std::string m_networkStartup;
|
||||
unsigned int m_networkInactivityTimeout;
|
||||
bool m_networkRevert;
|
||||
bool m_networkDebug;
|
||||
bool m_ysfNetworkEnabled;
|
||||
unsigned int m_ysfNetworkPort;
|
||||
std::string m_ysfNetworkHosts;
|
||||
unsigned int m_ysfNetworkReloadTime;
|
||||
std::string m_ysfNetworkParrotAddress;
|
||||
unsigned int m_ysfNetworkParrotPort;
|
||||
std::string m_ysfNetworkYSF2DMRAddress;
|
||||
unsigned int m_ysfNetworkYSF2DMRPort;
|
||||
std::string m_ysfNetworkStartup;
|
||||
unsigned int m_ysfNetworkInactivityTimeout;
|
||||
bool m_ysfNetworkRevert;
|
||||
bool m_ysfNetworkDebug;
|
||||
|
||||
bool m_fcsNetworkEnabled;
|
||||
unsigned int m_fcsNetworkPort;
|
||||
bool m_fcsNetworkDebug;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012,2013,2015,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2012,2013,2015,2017,2018 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2011 by DV Developer Group. DJ0ABR
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -160,20 +160,29 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end)
|
|||
|
||||
WX_STATUS CDTMF::validate() const
|
||||
{
|
||||
if (m_command.length() != 6U)
|
||||
size_t length = m_command.length();
|
||||
if (length != 4U && length != 6U)
|
||||
return WXS_NONE;
|
||||
|
||||
if (m_command.at(0U) != '#')
|
||||
char first = m_command.at(0U);
|
||||
if (first != '#' && first != 'A')
|
||||
return WXS_NONE;
|
||||
|
||||
for (unsigned int i = 1U; i <= 6U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
return WXS_NONE;
|
||||
if (length == 4U) {
|
||||
for (unsigned int i = 1U; i <= 4U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
return WXS_NONE;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i = 1U; i <= 6U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
return WXS_NONE;
|
||||
}
|
||||
|
||||
if (m_command == "#99999")
|
||||
return WXS_DISCONNECT;
|
||||
}
|
||||
|
||||
if (m_command == "#99999")
|
||||
return WXS_DISCONNECT;
|
||||
|
||||
return WXS_CONNECT;
|
||||
}
|
||||
|
||||
|
|
176
YSFGateway/FCSNetwork.cpp
Normal file
176
YSFGateway/FCSNetwork.cpp
Normal file
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Copyright (C) 2009-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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "YSFDefines.h"
|
||||
#include "FCSNetwork.h"
|
||||
#include "Utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
const unsigned int BUFFER_LENGTH = 200U;
|
||||
|
||||
CFCSNetwork::CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) :
|
||||
m_socket(address, port),
|
||||
m_debug(debug),
|
||||
m_address(),
|
||||
m_port(0U),
|
||||
m_poll(NULL),
|
||||
m_unlink(NULL),
|
||||
m_buffer(1000U, "FCS Network Buffer")
|
||||
{
|
||||
m_poll = new unsigned char[14U];
|
||||
::memcpy(m_poll + 0U, "YSFP", 4U);
|
||||
|
||||
m_unlink = new unsigned char[14U];
|
||||
::memcpy(m_unlink + 0U, "YSFU", 4U);
|
||||
|
||||
std::string node = callsign;
|
||||
node.resize(YSF_CALLSIGN_LENGTH, ' ');
|
||||
|
||||
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) {
|
||||
m_poll[i + 4U] = node.at(i);
|
||||
m_unlink[i + 4U] = node.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, bool debug) :
|
||||
m_socket(port),
|
||||
m_debug(debug),
|
||||
m_address(),
|
||||
m_port(0U),
|
||||
m_poll(NULL),
|
||||
m_unlink(NULL),
|
||||
m_buffer(1000U, "FCS Network Buffer")
|
||||
{
|
||||
m_poll = new unsigned char[14U];
|
||||
::memcpy(m_poll + 0U, "YSFP", 4U);
|
||||
|
||||
m_unlink = new unsigned char[14U];
|
||||
::memcpy(m_unlink + 0U, "YSFU", 4U);
|
||||
|
||||
std::string node = callsign;
|
||||
node.resize(YSF_CALLSIGN_LENGTH, ' ');
|
||||
|
||||
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) {
|
||||
m_poll[i + 4U] = node.at(i);
|
||||
m_unlink[i + 4U] = node.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
CFCSNetwork::~CFCSNetwork()
|
||||
{
|
||||
delete[] m_poll;
|
||||
}
|
||||
|
||||
bool CFCSNetwork::open()
|
||||
{
|
||||
LogMessage("Opening FCS network connection");
|
||||
|
||||
return m_socket.open();
|
||||
}
|
||||
|
||||
void CFCSNetwork::setDestination(const in_addr& address, unsigned int port)
|
||||
{
|
||||
m_address = address;
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
void CFCSNetwork::clearDestination()
|
||||
{
|
||||
m_address.s_addr = INADDR_NONE;
|
||||
m_port = 0U;
|
||||
}
|
||||
|
||||
bool CFCSNetwork::write(const unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
if (m_port == 0U)
|
||||
return true;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Sent", data, 155U);
|
||||
|
||||
return m_socket.write(data, 155U, m_address, m_port);
|
||||
}
|
||||
|
||||
bool CFCSNetwork::writePoll()
|
||||
{
|
||||
if (m_port == 0U)
|
||||
return true;
|
||||
|
||||
return m_socket.write(m_poll, 14U, m_address, m_port);
|
||||
}
|
||||
|
||||
bool CFCSNetwork::writeUnlink()
|
||||
{
|
||||
if (m_port == 0U)
|
||||
return true;
|
||||
|
||||
return m_socket.write(m_unlink, 14U, m_address, m_port);
|
||||
}
|
||||
|
||||
void CFCSNetwork::clock(unsigned int ms)
|
||||
{
|
||||
if (m_port == 0U)
|
||||
return;
|
||||
|
||||
unsigned char buffer[BUFFER_LENGTH];
|
||||
|
||||
in_addr address;
|
||||
unsigned int port;
|
||||
int length = m_socket.read(buffer, BUFFER_LENGTH, address, port);
|
||||
if (length <= 0)
|
||||
return;
|
||||
|
||||
if (address.s_addr != m_address.s_addr || port != m_port)
|
||||
return;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Received", buffer, length);
|
||||
|
||||
unsigned char len = length;
|
||||
m_buffer.addData(&len, 1U);
|
||||
|
||||
m_buffer.addData(buffer, length);
|
||||
}
|
||||
|
||||
unsigned int CFCSNetwork::read(unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
if (m_buffer.isEmpty())
|
||||
return 0U;
|
||||
|
||||
unsigned char len = 0U;
|
||||
m_buffer.getData(&len, 1U);
|
||||
|
||||
m_buffer.getData(data, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void CFCSNetwork::close()
|
||||
{
|
||||
m_socket.close();
|
||||
|
||||
LogMessage("Closing FCS network connection");
|
||||
}
|
61
YSFGateway/FCSNetwork.h
Normal file
61
YSFGateway/FCSNetwork.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2009-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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef FCSNetwork_H
|
||||
#define FCSNetwork_H
|
||||
|
||||
#include "YSFDefines.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "RingBuffer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class CFCSNetwork {
|
||||
public:
|
||||
CFCSNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug);
|
||||
CFCSNetwork(unsigned int port, const std::string& callsign, bool debug);
|
||||
~CFCSNetwork();
|
||||
|
||||
bool open();
|
||||
|
||||
void setDestination(const in_addr& address, unsigned int port);
|
||||
void clearDestination();
|
||||
|
||||
bool write(const unsigned char* data);
|
||||
|
||||
bool writePoll();
|
||||
bool writeUnlink();
|
||||
|
||||
unsigned int read(unsigned char* data);
|
||||
|
||||
void clock(unsigned int ms);
|
||||
|
||||
void close();
|
||||
|
||||
private:
|
||||
CUDPSocket m_socket;
|
||||
bool m_debug;
|
||||
in_addr m_address;
|
||||
unsigned int m_port;
|
||||
unsigned char* m_poll;
|
||||
unsigned char* m_unlink;
|
||||
CRingBuffer<unsigned char> m_buffer;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
|||
LIBS = -lm -lpthread
|
||||
LDFLAGS = -g
|
||||
|
||||
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
|
||||
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
|
||||
UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o
|
||||
|
||||
all: YSFGateway
|
||||
|
|
|
@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
|||
LIBS = -lm -lpthread -lsocket
|
||||
LDFLAGS = -g
|
||||
|
||||
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
|
||||
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
|
||||
UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o
|
||||
|
||||
all: YSFGateway
|
||||
|
|
|
@ -82,6 +82,7 @@ m_gps(NULL),
|
|||
m_wiresX(NULL),
|
||||
m_dtmf(NULL),
|
||||
m_ysfNetwork(NULL),
|
||||
m_fcsNetwork(NULL),
|
||||
m_linked(false),
|
||||
m_exclude(false)
|
||||
{
|
||||
|
@ -168,7 +169,7 @@ int CYSFGateway::run()
|
|||
m_callsign = m_conf.getCallsign();
|
||||
m_suffix = m_conf.getSuffix();
|
||||
|
||||
bool debug = m_conf.getNetworkDebug();
|
||||
bool debug = m_conf.getYSFNetworkDebug();
|
||||
in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress());
|
||||
unsigned int rptPort = m_conf.getRptPort();
|
||||
std::string myAddress = m_conf.getMyAddress();
|
||||
|
@ -184,9 +185,9 @@ int CYSFGateway::run()
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned int netPort = m_conf.getNetworkPort();
|
||||
unsigned int ysfPort = m_conf.getYSFNetworkPort();
|
||||
|
||||
m_ysfNetwork = new CYSFNetwork(netPort, m_callsign, debug);
|
||||
m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug);
|
||||
ret = m_ysfNetwork->open();
|
||||
if (!ret) {
|
||||
::LogError("Cannot open the YSF reflector network port");
|
||||
|
@ -194,17 +195,27 @@ int CYSFGateway::run()
|
|||
return 1;
|
||||
}
|
||||
|
||||
CTimer inactivityTimer(1000U, m_conf.getNetworkInactivityTimeout() * 60U);
|
||||
unsigned int fcsPort = m_conf.getFCSNetworkPort();
|
||||
|
||||
m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, debug);
|
||||
ret = m_fcsNetwork->open();
|
||||
if (!ret) {
|
||||
::LogError("Cannot open the FCS reflector network port");
|
||||
::LogFinalise();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CTimer inactivityTimer(1000U, m_conf.getYSFNetworkInactivityTimeout() * 60U);
|
||||
CTimer lostTimer(1000U, 120U);
|
||||
CTimer pollTimer(1000U, 5U);
|
||||
|
||||
bool revert = m_conf.getNetworkRevert();
|
||||
std::string startup = m_conf.getNetworkStartup();
|
||||
bool revert = m_conf.getYSFNetworkRevert();
|
||||
std::string startup = m_conf.getYSFNetworkStartup();
|
||||
|
||||
bool networkEnabled = m_conf.getNetworkEnabled();
|
||||
if (networkEnabled) {
|
||||
std::string fileName = m_conf.getNetworkHosts();
|
||||
unsigned int reloadTime = m_conf.getNetworkReloadTime();
|
||||
bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled();
|
||||
if (ysfNetworkEnabled) {
|
||||
std::string fileName = m_conf.getYSFNetworkHosts();
|
||||
unsigned int reloadTime = m_conf.getYSFNetworkReloadTime();
|
||||
|
||||
m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime);
|
||||
m_dtmf = new CDTMF;
|
||||
|
@ -215,14 +226,14 @@ int CYSFGateway::run()
|
|||
|
||||
m_wiresX->setInfo(name, txFrequency, rxFrequency);
|
||||
|
||||
std::string address = m_conf.getNetworkParrotAddress();
|
||||
unsigned int port = m_conf.getNetworkParrotPort();
|
||||
std::string address = m_conf.getYSFNetworkParrotAddress();
|
||||
unsigned int port = m_conf.getYSFNetworkParrotPort();
|
||||
|
||||
if (port > 0U)
|
||||
m_wiresX->setParrot(address, port);
|
||||
|
||||
address = m_conf.getNetworkYSF2DMRAddress();
|
||||
port = m_conf.getNetworkYSF2DMRPort();
|
||||
address = m_conf.getYSFNetworkYSF2DMRAddress();
|
||||
port = m_conf.getYSFNetworkYSF2DMRPort();
|
||||
|
||||
if (port > 0U)
|
||||
m_wiresX->setYSF2DMR(address, port);
|
||||
|
@ -377,7 +388,7 @@ int CYSFGateway::run()
|
|||
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
|
||||
}
|
||||
|
||||
if (networkEnabled && m_linked && !m_exclude) {
|
||||
if (ysfNetworkEnabled && m_linked && !m_exclude) {
|
||||
m_ysfNetwork->write(buffer);
|
||||
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
||||
inactivityTimer.start();
|
||||
|
@ -393,7 +404,7 @@ int CYSFGateway::run()
|
|||
}
|
||||
|
||||
while (m_ysfNetwork->read(buffer) > 0U) {
|
||||
if (networkEnabled && m_linked) {
|
||||
if (ysfNetworkEnabled && m_linked) {
|
||||
// Only pass through YSF data packets
|
||||
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
||||
rptNetwork.write(buffer);
|
||||
|
@ -407,6 +418,7 @@ int CYSFGateway::run()
|
|||
|
||||
rptNetwork.clock(ms);
|
||||
m_ysfNetwork->clock(ms);
|
||||
m_fcsNetwork->clock(ms);
|
||||
if (m_gps != NULL)
|
||||
m_gps->clock(ms);
|
||||
if (m_wiresX != NULL)
|
||||
|
@ -484,6 +496,7 @@ int CYSFGateway::run()
|
|||
|
||||
rptNetwork.close();
|
||||
m_ysfNetwork->close();
|
||||
m_fcsNetwork->close();
|
||||
|
||||
if (m_gps != NULL) {
|
||||
m_gps->close();
|
||||
|
@ -491,6 +504,7 @@ int CYSFGateway::run()
|
|||
}
|
||||
|
||||
delete m_ysfNetwork;
|
||||
delete m_fcsNetwork;
|
||||
delete m_wiresX;
|
||||
delete m_dtmf;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define YSFGateway_H
|
||||
|
||||
#include "YSFNetwork.h"
|
||||
#include "FCSNetwork.h"
|
||||
#include "WiresX.h"
|
||||
#include "Conf.h"
|
||||
#include "DTMF.h"
|
||||
|
@ -43,6 +44,7 @@ private:
|
|||
CWiresX* m_wiresX;
|
||||
CDTMF* m_dtmf;
|
||||
CYSFNetwork* m_ysfNetwork;
|
||||
CFCSNetwork* m_fcsNetwork;
|
||||
bool m_linked;
|
||||
bool m_exclude;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ Port=14580
|
|||
Password=9999
|
||||
Description=APRS Description
|
||||
|
||||
[Network]
|
||||
[YSF Network]
|
||||
Enable=1
|
||||
Port=42000
|
||||
Hosts=./YSFHosts.txt
|
||||
|
@ -46,3 +46,8 @@ YSF2DMRPort=42013
|
|||
InactivityTimeout=10
|
||||
# Revert=0
|
||||
Debug=0
|
||||
|
||||
[FCS Network]
|
||||
Enable=1
|
||||
Port=42000
|
||||
Debug=0
|
||||
|
|
|
@ -151,6 +151,7 @@
|
|||
<ClInclude Include="Conf.h" />
|
||||
<ClInclude Include="CRC.h" />
|
||||
<ClInclude Include="DTMF.h" />
|
||||
<ClInclude Include="FCSNetwork.h" />
|
||||
<ClInclude Include="Golay24128.h" />
|
||||
<ClInclude Include="GPS.h" />
|
||||
<ClInclude Include="Log.h" />
|
||||
|
@ -178,6 +179,7 @@
|
|||
<ClCompile Include="Conf.cpp" />
|
||||
<ClCompile Include="CRC.cpp" />
|
||||
<ClCompile Include="DTMF.cpp" />
|
||||
<ClCompile Include="FCSNetwork.cpp" />
|
||||
<ClCompile Include="Golay24128.cpp" />
|
||||
<ClCompile Include="GPS.cpp" />
|
||||
<ClCompile Include="Log.cpp" />
|
||||
|
|
|
@ -86,6 +86,9 @@
|
|||
<ClInclude Include="YSFReflectors.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FCSNetwork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StopWatch.cpp">
|
||||
|
@ -154,5 +157,8 @@
|
|||
<ClCompile Include="YSFReflectors.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FCSNetwork.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Add table
Reference in a new issue