|
|
@ -119,7 +119,8 @@ int CYSFGateway::run()
|
|
|
|
if (pid == -1) {
|
|
|
|
if (pid == -1) {
|
|
|
|
::LogWarning("Couldn't fork() , exiting");
|
|
|
|
::LogWarning("Couldn't fork() , exiting");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
} else if (pid != 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (pid != 0)
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
// Create new session and process group
|
|
|
|
// Create new session and process group
|
|
|
@ -172,7 +173,7 @@ int CYSFGateway::run()
|
|
|
|
m_callsign = m_conf.getCallsign();
|
|
|
|
m_callsign = m_conf.getCallsign();
|
|
|
|
m_suffix = m_conf.getSuffix();
|
|
|
|
m_suffix = m_conf.getSuffix();
|
|
|
|
|
|
|
|
|
|
|
|
bool debug = m_conf.getYSFNetworkDebug();
|
|
|
|
bool debug = m_conf.getNetworkDebug();
|
|
|
|
in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress());
|
|
|
|
in_addr rptAddress = CUDPSocket::lookup(m_conf.getRptAddress());
|
|
|
|
unsigned int rptPort = m_conf.getRptPort();
|
|
|
|
unsigned int rptPort = m_conf.getRptPort();
|
|
|
|
std::string myAddress = m_conf.getMyAddress();
|
|
|
|
std::string myAddress = m_conf.getMyAddress();
|
|
|
@ -188,6 +189,8 @@ int CYSFGateway::run()
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled();
|
|
|
|
|
|
|
|
if (ysfNetworkEnabled) {
|
|
|
|
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, debug);
|
|
|
@ -197,7 +200,10 @@ int CYSFGateway::run()
|
|
|
|
::LogFinalise();
|
|
|
|
::LogFinalise();
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled();
|
|
|
|
|
|
|
|
if (fcsNetworkEnabled) {
|
|
|
|
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();
|
|
|
@ -212,39 +218,26 @@ int CYSFGateway::run()
|
|
|
|
::LogFinalise();
|
|
|
|
::LogFinalise();
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_inactivityTimer.setTimeout(m_conf.getYSFNetworkInactivityTimeout() * 60U);
|
|
|
|
m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U);
|
|
|
|
|
|
|
|
|
|
|
|
bool revert = m_conf.getYSFNetworkRevert();
|
|
|
|
|
|
|
|
std::string startup = m_conf.getYSFNetworkStartup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled();
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string name = m_conf.getName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_wiresX->setInfo(name, txFrequency, rxFrequency);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string address = m_conf.getYSFNetworkParrotAddress();
|
|
|
|
bool revert = m_conf.getNetworkRevert();
|
|
|
|
unsigned int port = m_conf.getYSFNetworkParrotPort();
|
|
|
|
std::string startup = m_conf.getNetworkStartup();
|
|
|
|
|
|
|
|
|
|
|
|
if (port > 0U)
|
|
|
|
if (!startup.empty()) {
|
|
|
|
m_wiresX->setParrot(address, port);
|
|
|
|
if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) {
|
|
|
|
|
|
|
|
LogMessage("Automatic connection to %s", startup.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
address = m_conf.getYSFNetworkYSF2DMRAddress();
|
|
|
|
m_fcsNetwork->writeLink(startup);
|
|
|
|
port = m_conf.getYSFNetworkYSF2DMRPort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port > 0U)
|
|
|
|
if (!revert)
|
|
|
|
m_wiresX->setYSF2DMR(address, port);
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
|
|
|
|
|
|
|
|
m_wiresX->start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
|
|
|
|
|
|
|
|
if (!startup.empty()) {
|
|
|
|
m_linkType = LINK_FCS;
|
|
|
|
|
|
|
|
} else if (m_ysfNetwork != NULL) {
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector(startup);
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector(startup);
|
|
|
|
if (reflector != NULL) {
|
|
|
|
if (reflector != NULL) {
|
|
|
|
LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
|
LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
@ -267,6 +260,8 @@ int CYSFGateway::run()
|
|
|
|
|
|
|
|
|
|
|
|
LogMessage("Starting YSFGateway-%s", VERSION);
|
|
|
|
LogMessage("Starting YSFGateway-%s", VERSION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createWiresX(&rptNetwork);
|
|
|
|
|
|
|
|
|
|
|
|
createGPS();
|
|
|
|
createGPS();
|
|
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
@ -284,7 +279,6 @@ int CYSFGateway::run()
|
|
|
|
// Don't send out control data
|
|
|
|
// Don't send out control data
|
|
|
|
m_exclude = (dt == YSF_DT_DATA_FR_MODE);
|
|
|
|
m_exclude = (dt == YSF_DT_DATA_FR_MODE);
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
processWiresX(buffer, fi, dt, fn, ft);
|
|
|
|
processWiresX(buffer, fi, dt, fn, ft);
|
|
|
|
|
|
|
|
|
|
|
|
processDTMF(buffer, dt);
|
|
|
|
processDTMF(buffer, dt);
|
|
|
@ -293,13 +287,13 @@ int CYSFGateway::run()
|
|
|
|
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
|
|
|
|
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ysfNetworkEnabled && m_linkType == LINK_YSF && !m_exclude) {
|
|
|
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) {
|
|
|
|
m_ysfNetwork->write(buffer);
|
|
|
|
m_ysfNetwork->write(buffer);
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fcsNetworkEnabled && m_linkType == LINK_FCS && !m_exclude) {
|
|
|
|
if (m_fcsNetwork != NULL && m_linkType == LINK_FCS && !m_exclude) {
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
|
|
|
|
m_fcsNetwork->write(buffer);
|
|
|
|
m_fcsNetwork->write(buffer);
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_inactivityTimer.start();
|
|
|
@ -314,8 +308,9 @@ int CYSFGateway::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_ysfNetwork != NULL) {
|
|
|
|
while (m_ysfNetwork->read(buffer) > 0U) {
|
|
|
|
while (m_ysfNetwork->read(buffer) > 0U) {
|
|
|
|
if (ysfNetworkEnabled && m_linkType == LINK_YSF) {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
// Only pass through YSF data packets
|
|
|
|
// Only pass through YSF data packets
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
|
|
|
rptNetwork.write(buffer);
|
|
|
|
rptNetwork.write(buffer);
|
|
|
@ -323,36 +318,42 @@ int CYSFGateway::run()
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_fcsNetwork != NULL) {
|
|
|
|
while (m_fcsNetwork->read(buffer) > 0U) {
|
|
|
|
while (m_fcsNetwork->read(buffer) > 0U) {
|
|
|
|
if (fcsNetworkEnabled && m_linkType == LINK_FCS) {
|
|
|
|
if (m_linkType == LINK_FCS) {
|
|
|
|
|
|
|
|
// Only pass through YSF data packets
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
|
|
|
|
rptNetwork.write(buffer);
|
|
|
|
rptNetwork.write(buffer);
|
|
|
|
|
|
|
|
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int ms = stopWatch.elapsed();
|
|
|
|
unsigned int ms = stopWatch.elapsed();
|
|
|
|
stopWatch.start();
|
|
|
|
stopWatch.start();
|
|
|
|
|
|
|
|
|
|
|
|
rptNetwork.clock(ms);
|
|
|
|
rptNetwork.clock(ms);
|
|
|
|
|
|
|
|
if (m_ysfNetwork != NULL)
|
|
|
|
m_ysfNetwork->clock(ms);
|
|
|
|
m_ysfNetwork->clock(ms);
|
|
|
|
|
|
|
|
if (m_fcsNetwork != NULL)
|
|
|
|
m_fcsNetwork->clock(ms);
|
|
|
|
m_fcsNetwork->clock(ms);
|
|
|
|
if (m_gps != NULL)
|
|
|
|
if (m_gps != NULL)
|
|
|
|
m_gps->clock(ms);
|
|
|
|
m_gps->clock(ms);
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
m_wiresX->clock(ms);
|
|
|
|
m_wiresX->clock(ms);
|
|
|
|
|
|
|
|
|
|
|
|
m_inactivityTimer.clock(ms);
|
|
|
|
m_inactivityTimer.clock(ms);
|
|
|
|
if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) {
|
|
|
|
if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
CYSFReflector* reflector = NULL;
|
|
|
|
CYSFReflector* reflector = NULL;
|
|
|
|
if (revert && !startup.empty() && m_wiresX != NULL)
|
|
|
|
if (revert && !startup.empty())
|
|
|
|
reflector = m_wiresX->getReflector(startup);
|
|
|
|
reflector = m_wiresX->getReflector(startup);
|
|
|
|
|
|
|
|
|
|
|
|
if (reflector != NULL) {
|
|
|
|
if (reflector != NULL) {
|
|
|
|
LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
|
LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
m_wiresX->processConnect(reflector);
|
|
|
|
m_wiresX->processConnect(reflector);
|
|
|
|
|
|
|
|
|
|
|
|
m_ysfNetwork->writeUnlink(3U);
|
|
|
|
m_ysfNetwork->writeUnlink(3U);
|
|
|
@ -364,7 +365,6 @@ int CYSFGateway::run()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
LogMessage("Disconnecting due to inactivity");
|
|
|
|
LogMessage("Disconnecting due to inactivity");
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
|
|
|
|
|
|
|
|
m_ysfNetwork->writeUnlink(3U);
|
|
|
|
m_ysfNetwork->writeUnlink(3U);
|
|
|
@ -383,7 +383,7 @@ int CYSFGateway::run()
|
|
|
|
if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) {
|
|
|
|
if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) {
|
|
|
|
LogWarning("Link has failed, polls lost");
|
|
|
|
LogWarning("Link has failed, polls lost");
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
if (m_linkType == LINK_YSF)
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
|
|
|
|
|
|
|
|
if (m_fcsNetwork != NULL)
|
|
|
|
if (m_fcsNetwork != NULL)
|
|
|
@ -403,16 +403,22 @@ int CYSFGateway::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rptNetwork.close();
|
|
|
|
rptNetwork.close();
|
|
|
|
m_ysfNetwork->close();
|
|
|
|
|
|
|
|
m_fcsNetwork->close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_gps != NULL) {
|
|
|
|
if (m_gps != NULL) {
|
|
|
|
m_gps->close();
|
|
|
|
m_gps->close();
|
|
|
|
delete m_gps;
|
|
|
|
delete m_gps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_ysfNetwork != NULL) {
|
|
|
|
|
|
|
|
m_ysfNetwork->close();
|
|
|
|
delete m_ysfNetwork;
|
|
|
|
delete m_ysfNetwork;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_fcsNetwork != NULL) {
|
|
|
|
|
|
|
|
m_fcsNetwork->close();
|
|
|
|
delete m_fcsNetwork;
|
|
|
|
delete m_fcsNetwork;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete m_wiresX;
|
|
|
|
delete m_wiresX;
|
|
|
|
|
|
|
|
|
|
|
|
::LogFinalise();
|
|
|
|
::LogFinalise();
|
|
|
@ -447,6 +453,36 @@ void CYSFGateway::createGPS()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(rptNetwork != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string fileName = m_conf.getYSFNetworkHosts();
|
|
|
|
|
|
|
|
unsigned int reloadTime = m_conf.getYSFNetworkReloadTime();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, fileName, reloadTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string name = m_conf.getName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int txFrequency = m_conf.getTxFrequency();
|
|
|
|
|
|
|
|
unsigned int rxFrequency = m_conf.getRxFrequency();
|
|
|
|
|
|
|
|
m_wiresX->setInfo(name, txFrequency, rxFrequency);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string address = m_conf.getYSFNetworkParrotAddress();
|
|
|
|
|
|
|
|
unsigned int port = m_conf.getYSFNetworkParrotPort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port > 0U)
|
|
|
|
|
|
|
|
m_wiresX->setParrot(address, port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = m_conf.getYSFNetworkYSF2DMRAddress();
|
|
|
|
|
|
|
|
port = m_conf.getYSFNetworkYSF2DMRPort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port > 0U)
|
|
|
|
|
|
|
|
m_wiresX->setYSF2DMR(address, port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_wiresX->start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft)
|
|
|
|
void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(buffer != NULL);
|
|
|
|
assert(buffer != NULL);
|
|
|
@ -521,7 +557,6 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt)
|
|
|
|
std::string id = m_dtmf.getReflector();
|
|
|
|
std::string id = m_dtmf.getReflector();
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector(id);
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector(id);
|
|
|
|
if (reflector != NULL) {
|
|
|
|
if (reflector != NULL) {
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
m_wiresX->processConnect(reflector);
|
|
|
|
m_wiresX->processConnect(reflector);
|
|
|
|
|
|
|
|
|
|
|
|
if (m_linkType == LINK_YSF)
|
|
|
|
if (m_linkType == LINK_YSF)
|
|
|
@ -570,7 +605,6 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case WXS_DISCONNECT:
|
|
|
|
case WXS_DISCONNECT:
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
if (m_wiresX != NULL)
|
|
|
|
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
m_wiresX->processDisconnect();
|
|
|
|
|
|
|
|
|
|
|
|
LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U);
|
|
|
|
LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U);
|
|
|
|