1
0
Fork 0

applies changes made by OE1KBC

<http://ycs-wiki.xreflector.net/doku.php?id=start#supported_hardware>
allows the use of "Options=10,20" in YSFGateway.ini
ycs232-kbc ycs232-kbc-20210123
Dominic Reich 2 years ago
parent 8203003add
commit c5491958e4
No known key found for this signature in database
GPG Key ID: A4724D0F0EBE1253

@ -29,7 +29,7 @@ const char* FCS_VERSION = "MMDVM";
const unsigned int BUFFER_LENGTH = 200U; const unsigned int BUFFER_LENGTH = 200U;
CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug) : CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, const std::string& name, unsigned int id, bool debug) :
m_socket(port), m_socket(port),
m_debug(debug), m_debug(debug),
m_addr(), m_addr(),
@ -38,6 +38,7 @@ m_ping(NULL),
m_options(NULL), m_options(NULL),
m_opt(), m_opt(),
m_info(NULL), m_info(NULL),
m_info_long(NULL),
m_reflector(), m_reflector(),
m_print(), m_print(),
m_buffer(1000U, "FCS Network Buffer"), m_buffer(1000U, "FCS Network Buffer"),
@ -46,9 +47,13 @@ m_pingTimer(1000U, 0U, 800U),
m_resetTimer(1000U, 1U), m_resetTimer(1000U, 1U),
m_state(FCS_UNLINKED) m_state(FCS_UNLINKED)
{ {
m_info = new unsigned char[100U]; m_info_long = new unsigned char[100U];
::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); ::sprintf((char*)m_info_long, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id);
::memset(m_info + 43U, ' ', 57U); ::memset(m_info_long + 43U, ' ', 57U);
m_info = new unsigned char[80U];
::sprintf((char*)m_info, "FCSIFCS99999%9u%9u%-6.6s%-20.20s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), name.c_str(), FCS_VERSION, id); // KBC 2020-09-07
::memset(m_info + 75U, ' ', 5U);
m_ping = new unsigned char[25U]; m_ping = new unsigned char[25U];
::memcpy(m_ping + 0U, "PING", 4U); ::memcpy(m_ping + 0U, "PING", 4U);
@ -65,6 +70,7 @@ m_state(FCS_UNLINKED)
CFCSNetwork::~CFCSNetwork() CFCSNetwork::~CFCSNetwork()
{ {
delete[] m_info; delete[] m_info;
delete[] m_info_long;
delete[] m_ping; delete[] m_ping;
delete[] m_options; delete[] m_options;
} }
@ -198,14 +204,15 @@ void CFCSNetwork::clock(unsigned int ms)
if (m_state == FCS_LINKING) if (m_state == FCS_LINKING)
LogMessage("Linked to %s", m_print.c_str()); LogMessage("Linked to %s", m_print.c_str());
m_state = FCS_LINKED; m_state = FCS_LINKED;
writeInfo(); writeInfo(m_print);
writeOptions(m_print); writeOptions(m_print);
} }
if (length == 10 && m_state == FCS_LINKING) { if (length == 10 && m_state == FCS_LINKING) {
LogMessage("Linked to %s", m_print.c_str()); LogMessage("Linked to %s", m_print.c_str());
m_state = FCS_LINKED; m_state = FCS_LINKED;
writeInfo(); writeInfoLong(m_print);
writeInfo(m_print);
writeOptions(m_print); writeOptions(m_print);
} }
@ -262,15 +269,28 @@ void CFCSNetwork::close()
LogMessage("Closing FCS network connection"); LogMessage("Closing FCS network connection");
} }
void CFCSNetwork::writeInfo() void CFCSNetwork::writeInfo(const std::string& reflector)
{ {
if (m_state != FCS_LINKED) if (m_state != FCS_LINKED)
return; return;
::memcpy(m_info + 4U, (reflector.substr(0,6)+reflector.substr(7,2)).c_str(), 8U);
if (m_debug) if (m_debug)
CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U); CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U);
m_socket.write(m_info, 100U, m_addr, m_addrLen); m_socket.write(m_info, 80U, m_addr, m_addrLen);
}
void CFCSNetwork::writeInfoLong(const std::string& reflector)
{
if (m_state != FCS_LINKED)
return;
if (m_debug)
CUtils::dump(1U, "FCS Network Data Sent long", m_info_long, 100U);
m_socket.write(m_info_long, 100U, m_addr, m_addrLen);
} }
void CFCSNetwork::writePing() void CFCSNetwork::writePing()
@ -292,7 +312,7 @@ void CFCSNetwork::writeOptions(const std::string& reflector)
if (m_opt.size() < 1) if (m_opt.size() < 1)
return; return;
::memset(m_options + 14U, 0x20U, 36U); ::memset(m_options + 4U, 0x20U, 46U);
::memcpy(m_options + 4U, (reflector.substr(0,6)+reflector.substr(7,2)).c_str(), 8U); ::memcpy(m_options + 4U, (reflector.substr(0,6)+reflector.substr(7,2)).c_str(), 8U);
::memcpy(m_options + 12U, m_opt.c_str(), m_opt.size()); ::memcpy(m_options + 12U, m_opt.c_str(), m_opt.size());

@ -36,7 +36,7 @@ enum FCS_STATE {
class CFCSNetwork { class CFCSNetwork {
public: public:
CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug); CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, const std::string& name, unsigned int id, bool debug);
~CFCSNetwork(); ~CFCSNetwork();
bool open(); bool open();
@ -65,7 +65,8 @@ private:
unsigned char* m_ping; unsigned char* m_ping;
unsigned char* m_options; unsigned char* m_options;
std::string m_opt; std::string m_opt;
unsigned char* m_info; unsigned char* m_info;
unsigned char* m_info_long;
std::string m_reflector; std::string m_reflector;
std::string m_print; std::string m_print;
CRingBuffer<unsigned char> m_buffer; CRingBuffer<unsigned char> m_buffer;
@ -76,7 +77,8 @@ private:
FCS_STATE m_state; FCS_STATE m_state;
void writeOptions(const std::string& reflector); void writeOptions(const std::string& reflector);
void writeInfo(); void writeInfo(const std::string& reflector);
void writeInfoLong(const std::string& reflector);
void writePing(); void writePing();
}; };

@ -211,8 +211,14 @@ int CYSFGateway::run()
bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled();
if (ysfNetworkEnabled) { if (ysfNetworkEnabled) {
unsigned int txFrequency = m_conf.getTxFrequency();
unsigned int rxFrequency = m_conf.getRxFrequency();
std::string locator = calculateLocator();
std::string name = m_conf.getName();
unsigned int id = m_conf.getId();
unsigned int ysfPort = m_conf.getYSFNetworkPort(); unsigned int ysfPort = m_conf.getYSFNetworkPort();
m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, rxFrequency, txFrequency, locator, name, id, debug);
} }
m_fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); m_fcsNetworkEnabled = m_conf.getFCSNetworkEnabled();
@ -220,11 +226,12 @@ int CYSFGateway::run()
unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int txFrequency = m_conf.getTxFrequency();
unsigned int rxFrequency = m_conf.getRxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency();
std::string locator = calculateLocator(); std::string locator = calculateLocator();
std::string name = m_conf.getName(); // KBC 2020-09-07
unsigned int id = m_conf.getId(); unsigned int id = m_conf.getId();
unsigned int fcsPort = m_conf.getFCSNetworkPort(); unsigned int fcsPort = m_conf.getFCSNetworkPort();
m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug); m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, name, id, debug);
ret = m_fcsNetwork->open(); ret = m_fcsNetwork->open();
if (!ret) { if (!ret) {
::LogError("Cannot open the FCS reflector network port"); ::LogError("Cannot open the FCS reflector network port");

@ -61,6 +61,7 @@ private:
std::string m_current; std::string m_current;
std::string m_startup; std::string m_startup;
std::string m_options; std::string m_options;
std::string m_info;
bool m_exclude; bool m_exclude;
CTimer m_inactivityTimer; CTimer m_inactivityTimer;
CTimer m_lostTimer; CTimer m_lostTimer;

@ -1,75 +1,5 @@
[General]
Callsign=G9BF
Suffix=RPT
# Suffix=ND
Id=1234567
RptAddress=127.0.0.1
RptPort=3200
LocalAddress=127.0.0.1
LocalPort=4200
WiresXMakeUpper=1
WiresXCommandPassthrough=0
Debug=0
Daemon=0
[Info]
RXFrequency=430475000
TXFrequency=439475000
Power=1
Latitude=0.0
Longitude=0.0
Height=0
Name=Nowhere
Description=Multi-Mode Repeater
[Log]
# Logging levels, 0=No logging
DisplayLevel=1
FileLevel=1
FilePath=.
FileRoot=YSFGateway
FileRotate=1
[APRS]
Enable=0
Address=127.0.0.1
Port=8673
Description=APRS Description
Suffix=Y
[Network] [Network]
# Startup=FCS00120 Startup=DE-C4FM-Germany
# Startup=Alabama-Link # DG-ID OPTIONS e.g. 10,20 booked to MATRIX
# book DG-ID for Reflector Options=10;20;
# Options=20;21;
InactivityTimeout=10
Revert=0
Debug=0
[YSF Network]
Enable=1
Port=42000
Hosts=./YSFHosts.txt
ReloadTime=60
ParrotAddress=127.0.0.1
ParrotPort=42012
YSF2DMRAddress=127.0.0.1
YSF2DMRPort=42013
YSF2NXDNAddress=127.0.0.1
YSF2NXDNPort=42014
YSF2P25Address=127.0.0.1
YSF2P25Port=42015
[FCS Network]
Enable=1
Rooms=./FCSRooms.txt
Port=42001
[GPSD]
Enable=0
Address=127.0.0.1
Port=2947
[Remote Commands]
Enable=0
Port=6073

@ -25,6 +25,8 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
const char* YSF_VERSION = "YSFG-MMDVM";
const unsigned int BUFFER_LENGTH = 200U; const unsigned int BUFFER_LENGTH = 200U;
CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) :
@ -35,9 +37,10 @@ m_addrLen(0U),
m_poll(NULL), m_poll(NULL),
m_options(NULL), m_options(NULL),
m_opt(), m_opt(),
m_info(NULL),
m_unlink(NULL), m_unlink(NULL),
m_buffer(1000U, "YSF Network Buffer"), m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U), m_pollTimer(3000U, 5U),
m_name(), m_name(),
m_linked(false) m_linked(false)
{ {
@ -60,7 +63,7 @@ m_linked(false)
} }
} }
CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, bool debug) : CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, const std::string& name, unsigned int id, bool debug) :
m_socket(port), m_socket(port),
m_debug(debug), m_debug(debug),
m_addr(), m_addr(),
@ -68,9 +71,10 @@ m_addrLen(0U),
m_poll(NULL), m_poll(NULL),
m_options(NULL), m_options(NULL),
m_opt(), m_opt(),
m_info(NULL),
m_unlink(NULL), m_unlink(NULL),
m_buffer(1000U, "YSF Network Buffer"), m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U), m_pollTimer(3000U, 5U),
m_name(), m_name(),
m_linked(false) m_linked(false)
{ {
@ -83,6 +87,9 @@ m_linked(false)
m_options = new unsigned char[50U]; m_options = new unsigned char[50U];
::memcpy(m_options + 0U, "YSFO", 4U); ::memcpy(m_options + 0U, "YSFO", 4U);
m_info = new unsigned char[80U];
::sprintf((char*)m_info, "YSFI%-10.10s%9u%9u%-6.6s%-20.20s%-12.12s%7u ", callsign.c_str(), rxFrequency, txFrequency, locator.c_str(), name.c_str(), YSF_VERSION, id);
std::string node = callsign; std::string node = callsign;
node.resize(YSF_CALLSIGN_LENGTH, ' '); node.resize(YSF_CALLSIGN_LENGTH, ' ');
@ -98,6 +105,7 @@ CYSFNetwork::~CYSFNetwork()
delete[] m_poll; delete[] m_poll;
delete[] m_unlink; delete[] m_unlink;
delete[] m_options; delete[] m_options;
delete[] m_info;
} }
bool CYSFNetwork::open() bool CYSFNetwork::open()
@ -221,6 +229,14 @@ void CYSFNetwork::clock(unsigned int ms)
if (m_debug) if (m_debug)
CUtils::dump(1U, "YSF Network Data Received", buffer, length); CUtils::dump(1U, "YSF Network Data Received", buffer, length);
if (::memcmp(buffer, "YSFPONLINE", 10U) == 0 && m_linked) {
if (m_info != NULL)
m_socket.write(m_info, 80U, m_addr, m_addrLen);
if (m_options != NULL)
m_socket.write(m_options, 50U, m_addr, m_addrLen);
}
// Throw away any options messages // Throw away any options messages
if (::memcmp(buffer, "YSFO", 4U) == 0) if (::memcmp(buffer, "YSFO", 4U) == 0)
return; return;
@ -237,6 +253,9 @@ void CYSFNetwork::clock(unsigned int ms)
m_linked = true; m_linked = true;
if (m_info != NULL)
m_socket.write(m_info, 80U, m_addr, m_addrLen);
if (!m_opt.empty()) if (!m_opt.empty())
m_socket.write(m_options, 50U, m_addr, m_addrLen); m_socket.write(m_options, 50U, m_addr, m_addrLen);
} }

@ -30,7 +30,7 @@
class CYSFNetwork { class CYSFNetwork {
public: public:
CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug);
CYSFNetwork(unsigned int port, const std::string& callsign, bool debug); CYSFNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, const std::string& name, unsigned int id, bool debug);
~CYSFNetwork(); ~CYSFNetwork();
bool setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen); bool setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen);
@ -54,6 +54,7 @@ private:
unsigned char* m_poll; unsigned char* m_poll;
unsigned char* m_options; unsigned char* m_options;
std::string m_opt; std::string m_opt;
unsigned char* m_info;
unsigned char* m_unlink; unsigned char* m_unlink;
CRingBuffer<unsigned char> m_buffer; CRingBuffer<unsigned char> m_buffer;
CTimer m_pollTimer; CTimer m_pollTimer;

Loading…
Cancel
Save