|
|
@ -273,7 +273,8 @@ int CYSFGateway::run()
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
memset(buffer, 0U, 200U);
|
|
|
|
memset(buffer, 0U, 200U);
|
|
|
|
|
|
|
|
bool wx_tmp;
|
|
|
|
|
|
|
|
|
|
|
|
while (rptNetwork.read(buffer) > 0U) {
|
|
|
|
while (rptNetwork.read(buffer) > 0U) {
|
|
|
|
CYSFFICH fich;
|
|
|
|
CYSFFICH fich;
|
|
|
|
bool valid = fich.decode(buffer + 35U);
|
|
|
|
bool valid = fich.decode(buffer + 35U);
|
|
|
@ -282,14 +283,22 @@ int CYSFGateway::run()
|
|
|
|
unsigned char dt = fich.getDT();
|
|
|
|
unsigned char dt = fich.getDT();
|
|
|
|
|
|
|
|
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector();
|
|
|
|
CYSFReflector* reflector = m_wiresX->getReflector();
|
|
|
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && reflector->m_wiresX) {
|
|
|
|
if (reflector != NULL)
|
|
|
|
|
|
|
|
wx_tmp = reflector->m_wiresX;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
wx_tmp = false;
|
|
|
|
|
|
|
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && wx_tmp) {
|
|
|
|
processDTMF(buffer, dt);
|
|
|
|
processDTMF(buffer, dt);
|
|
|
|
processWiresX(buffer, fich, true, wiresXCommandPassthrough);
|
|
|
|
processWiresX(buffer, fich, true, wiresXCommandPassthrough);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
processDTMF(buffer, dt);
|
|
|
|
processDTMF(buffer, dt);
|
|
|
|
processWiresX(buffer, fich, false, wiresXCommandPassthrough);
|
|
|
|
processWiresX(buffer, fich, false, wiresXCommandPassthrough);
|
|
|
|
reflector = m_wiresX->getReflector(); //reflector may have changed
|
|
|
|
reflector = m_wiresX->getReflector(); //reflector may have changed
|
|
|
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && reflector->m_wiresX)
|
|
|
|
if (reflector != NULL)
|
|
|
|
|
|
|
|
wx_tmp = reflector->m_wiresX;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
wx_tmp = false;
|
|
|
|
|
|
|
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wx_tmp)
|
|
|
|
m_exclude = (dt == YSF_DT_DATA_FR_MODE);
|
|
|
|
m_exclude = (dt == YSF_DT_DATA_FR_MODE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -530,6 +539,11 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
|
|
|
|
if (port > 0U)
|
|
|
|
if (port > 0U)
|
|
|
|
m_wiresX->setYSF2P25(address, port);
|
|
|
|
m_wiresX->setYSF2P25(address, port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = m_conf.getYSFNetworkYSFDirectAddress();
|
|
|
|
|
|
|
|
port = m_conf.getYSFNetworkYSFDirectPort();
|
|
|
|
|
|
|
|
if (port > 0U)
|
|
|
|
|
|
|
|
m_wiresX->setYSFDirect(address, port);
|
|
|
|
|
|
|
|
|
|
|
|
std::string filename = m_conf.getFCSNetworkFile();
|
|
|
|
std::string filename = m_conf.getFCSNetworkFile();
|
|
|
|
if (m_fcsNetworkEnabled)
|
|
|
|
if (m_fcsNetworkEnabled)
|
|
|
|
readFCSRoomsFile(filename);
|
|
|
|
readFCSRoomsFile(filename);
|
|
|
@ -826,6 +840,8 @@ void CYSFGateway::startupLinking()
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
CYSFReflector* reflector = m_reflectors->findByName(m_startup);
|
|
|
|
CYSFReflector* reflector = m_reflectors->findByName(m_startup);
|
|
|
|
|
|
|
|
if (reflector == NULL)
|
|
|
|
|
|
|
|
reflector = m_reflectors->findById(m_startup);
|
|
|
|
if (reflector != NULL) {
|
|
|
|
if (reflector != NULL) {
|
|
|
|
LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
|
LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
|
|
|
|
|
|
|
|
|
|
|
@ -883,10 +899,11 @@ void CYSFGateway::processRemoteCommands()
|
|
|
|
int res = m_remoteSocket->read(buffer, 200U, addr, addrLen);
|
|
|
|
int res = m_remoteSocket->read(buffer, 200U, addr, addrLen);
|
|
|
|
if (res > 0) {
|
|
|
|
if (res > 0) {
|
|
|
|
buffer[res] = '\0';
|
|
|
|
buffer[res] = '\0';
|
|
|
|
if ((::memcmp(buffer + 0U, "LinkYSF", 7U) == 0) && (strlen((char*)buffer + 0U) > 8)) {
|
|
|
|
if ((::memcmp(buffer + 0U, "LinkYSF", 7U) == 0) && (strlen((char*)buffer + 0U) > 8) && (m_ysfNetwork != NULL)) {
|
|
|
|
std::string id = std::string((char*)(buffer + 8U));
|
|
|
|
std::string id = std::string((char*)(buffer + 7U));
|
|
|
|
// Left trim
|
|
|
|
// Left trim
|
|
|
|
id.erase(id.begin(), std::find_if(id.begin(), id.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
|
|
|
// id.erase(id.begin(), std::find_if(id.begin(), id.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
|
|
|
|
|
|
|
id.erase(std::remove_if(id.begin(), id.end(), [](char c) { return !std::isalnum(c); }), id.end());
|
|
|
|
CYSFReflector* reflector = m_reflectors->findById(id);
|
|
|
|
CYSFReflector* reflector = m_reflectors->findById(id);
|
|
|
|
if (reflector == NULL)
|
|
|
|
if (reflector == NULL)
|
|
|
|
reflector = m_reflectors->findByName(id);
|
|
|
|
reflector = m_reflectors->findByName(id);
|
|
|
@ -914,10 +931,11 @@ void CYSFGateway::processRemoteCommands()
|
|
|
|
LogWarning("Invalid YSF reflector id/name - \"%s\"", id.c_str());
|
|
|
|
LogWarning("Invalid YSF reflector id/name - \"%s\"", id.c_str());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ((::memcmp(buffer + 0U, "LinkFCS", 7U) == 0) && (strlen((char*)buffer + 0U) > 8)) {
|
|
|
|
} else if ((::memcmp(buffer + 0U, "LinkFCS", 7U) == 0) && (strlen((char*)buffer + 0U) > 8) && (m_fcsNetwork != NULL)) {
|
|
|
|
std::string raw = std::string((char*)(buffer + 8U));
|
|
|
|
std::string raw = std::string((char*)(buffer + 7U));
|
|
|
|
// Left trim
|
|
|
|
// Left trim
|
|
|
|
raw.erase(raw.begin(), std::find_if(raw.begin(), raw.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
|
|
|
// raw.erase(raw.begin(), std::find_if(raw.begin(), raw.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
|
|
|
|
|
|
|
raw.erase(std::remove_if(raw.begin(), raw.end(), [](char c) { return !std::isalnum(c); }), raw.end());
|
|
|
|
std::string id = "FCS00";
|
|
|
|
std::string id = "FCS00";
|
|
|
|
std::string idShort = "FCS";
|
|
|
|
std::string idShort = "FCS";
|
|
|
|
if (raw.length() == 3U) {
|
|
|
|
if (raw.length() == 3U) {
|
|
|
@ -941,7 +959,7 @@ void CYSFGateway::processRemoteCommands()
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_FCS;
|
|
|
|
|
|
|
|
|
|
|
|
LogMessage("Connect by remote command to %s", id.c_str());
|
|
|
|
LogMessage("Connect by remote command to %s", id.c_str());
|
|
|
|
|
|
|
|
|
|
|
@ -950,7 +968,7 @@ void CYSFGateway::processRemoteCommands()
|
|
|
|
m_current = id;
|
|
|
|
m_current = id;
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_linkType = LINK_FCS;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
LogMessage("Unknown reflector - %s", id.c_str());
|
|
|
|
LogMessage("Unknown reflector - %s", id.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|