Merge pull request #324 from shawnchain/feat-reconnect-on-wirex-dx-cmd

This commit is contained in:
Jonathan Naylor 2025-04-27 11:59:45 +01:00 committed by GitHub
commit 811caaa823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 4 deletions

View file

@ -260,7 +260,7 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
else {
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
processDX(source);
return WX_STATUS::NONE;
return WX_STATUS::RECONNECT_CURRENT;
} else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) {
processAll(source, m_command + 5U);
return WX_STATUS::NONE;

View file

@ -32,7 +32,8 @@ enum class WX_STATUS {
NONE,
CONNECT_YSF,
CONNECT_FCS,
DISCONNECT
DISCONNECT,
RECONNECT_CURRENT
};
enum class WXSI_STATUS {

View file

@ -433,7 +433,6 @@ int CYSFGateway::run()
m_fcsNetwork->clearDestination();
}
m_current.clear();
m_lostTimer.stop();
m_linkType = LINK_TYPE::NONE;
}
@ -454,7 +453,6 @@ int CYSFGateway::run()
m_fcsNetwork->clearDestination();
}
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_TYPE::NONE;
@ -669,6 +667,45 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
m_linkType = LINK_TYPE::NONE;
}
break;
case WX_STATUS::RECONNECT_CURRENT: {
if (m_wiresX->getReflector() == nullptr && !m_current.empty()) {
// trying to reconnect
if (m_current.substr(0U, 3U) == "FCS" && m_fcsNetwork != nullptr) {
m_inactivityTimer.stop();
m_lostTimer.stop();
bool ok = m_fcsNetwork->writeLink(m_current);
m_fcsNetwork->setOptions(m_options);
if (ok) {
LogMessage("Automatic (re-)connection to %s", m_current.c_str());
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_TYPE::FCS;;
}
} else if (m_ysfNetwork != nullptr) {
m_inactivityTimer.stop();
m_lostTimer.stop();
CYSFReflector* reflector = m_reflectors->findByName(m_current);
if (reflector != nullptr) {
LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
m_wiresX->setReflector(reflector);
m_ysfNetwork->setDestination(reflector->m_name, reflector->m_addr, reflector->m_addrLen);
m_ysfNetwork->setOptions(m_options);
m_ysfNetwork->writePoll(3U);
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_TYPE::YSF;
}
}
}
}
break;
default:
break;
}