1
0
Fork 0

Handle unknown FCS reflector better.

ycs232-kbc
Jonathan Naylor 7 years ago
parent 28a0a78d84
commit b56ef7051f

@ -100,19 +100,19 @@ void CFCSNetwork::write(const unsigned char* data)
m_socket.write(buffer, 130U, m_address, m_port); m_socket.write(buffer, 130U, m_address, m_port);
} }
void CFCSNetwork::writeLink(const std::string& reflector) bool CFCSNetwork::writeLink(const std::string& reflector)
{ {
if (m_port == 0U) { if (m_port == 0U) {
std::string name = reflector.substr(0U, 6U); std::string name = reflector.substr(0U, 6U);
if (m_addresses.count(name) == 0U) { if (m_addresses.count(name) == 0U) {
LogError("Unknown FCS reflector - %s", name.c_str()); LogError("Unknown FCS reflector - %s", name.c_str());
return; return false;
} }
m_address = m_addresses[name]; m_address = m_addresses[name];
if (m_address.s_addr == INADDR_NONE) { if (m_address.s_addr == INADDR_NONE) {
LogError("FCS reflector %s has no address", name.c_str()); LogError("FCS reflector %s has no address", name.c_str());
return; return false;
} }
} }
@ -127,6 +127,8 @@ void CFCSNetwork::writeLink(const std::string& reflector)
m_pingTimer.start(); m_pingTimer.start();
m_state = FCS_LINKING; m_state = FCS_LINKING;
return true;
} }
void CFCSNetwork::writeUnlink(unsigned int count) void CFCSNetwork::writeUnlink(unsigned int count)

@ -45,7 +45,7 @@ public:
void write(const unsigned char* data); void write(const unsigned char* data);
void writeLink(const std::string& reflector); bool writeLink(const std::string& reflector);
void writeUnlink(unsigned int count = 1U); void writeUnlink(unsigned int count = 1U);

@ -552,14 +552,20 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt)
if (m_linkType == LINK_FCS) if (m_linkType == LINK_FCS)
m_fcsNetwork->writeUnlink(3U); m_fcsNetwork->writeUnlink(3U);
LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U); m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_fcsNetwork->writeLink(id); LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U);
bool ok = m_fcsNetwork->writeLink(id);
if (ok) {
m_inactivityTimer.start(); m_inactivityTimer.start();
m_lostTimer.start(); m_lostTimer.start();
m_linkType = LINK_FCS; m_linkType = LINK_FCS;
} else {
LogMessage("Unknown reflector - %s", id.c_str());
}
} }
break; break;
case WXS_DISCONNECT: case WXS_DISCONNECT:
@ -652,14 +658,19 @@ void CYSFGateway::startupLinking()
if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { if (startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) {
LogMessage("Automatic (re-)connection to %s", startup.c_str()); LogMessage("Automatic (re-)connection to %s", startup.c_str());
m_fcsNetwork->writeLink(startup); m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
bool ok = m_fcsNetwork->writeLink(startup);
if (ok) {
if (!revert) if (!revert)
m_inactivityTimer.start(); m_inactivityTimer.start();
m_lostTimer.start(); m_lostTimer.start();
m_linkType = LINK_FCS; m_linkType = LINK_FCS;
} else {
LogMessage("Unknown reflector - %s", startup.c_str());
}
} else if (m_ysfNetwork != NULL) { } else if (m_ysfNetwork != NULL) {
CYSFReflector* reflector = m_wiresX->getReflector(startup); CYSFReflector* reflector = m_wiresX->getReflector(startup);
if (reflector != NULL) { if (reflector != NULL) {

Loading…
Cancel
Save