From 227b3a9b2f3a02d2a3686fb58111b7ad6ed02557 Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Mon, 24 Jan 2022 02:21:34 +0000 Subject: [PATCH] Add new remote command: - status: displays network connection status (n/a, conn, disc), just like DMRGateway/MMDVMHost. - host: display connected host, or NONE if disconnected (surrounded with double quotes). --- YSFGateway/YSFGateway.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 7a77713..9fbd9d1 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -977,6 +977,13 @@ void CYSFGateway::processRemoteCommands() m_lostTimer.stop(); m_linkType = LINK_NONE; } + } else if (::memcmp(buffer + 0U, "status", 6U) == 0) { + std::string state = std::string("ysf:") + (((m_ysfNetwork == NULL) && (m_fcsNetwork == NULL)) ? "n/a" : ((m_linkType != LINK_NONE) ? "conn" : "disc")); + m_remoteSocket->write((unsigned char*)state.c_str(), (unsigned int)state.length(), addr, addrLen); + } else if (::memcmp(buffer + 0U, "host", 4U) == 0) { + std::string ref = ((((m_ysfNetwork == NULL) && (m_fcsNetwork == NULL)) || (m_linkType == LINK_NONE)) ? "NONE" : m_current); + std::string host = std::string("ysf:\"") + ref + "\""; + m_remoteSocket->write((unsigned char*)host.c_str(), (unsigned int)host.length(), addr, addrLen); } else { CUtils::dump("Invalid remote command received", buffer, res); }