diff --git a/DMRGateway.cpp b/DMRGateway.cpp index a826f6a..a1813fc 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -2658,3 +2658,29 @@ void CDMRGateway::buildNetworkStatusNetworkString(std::string &str, const std::s str += name + ":"+ (((network == NULL) || (enabled == false)) ? "n/a" : (network->isConnected() ? "conn" : "disc")); } +void CDMRGateway::buildNetworkHostsString(std::string &str) +{ + str = ""; + buildNetworkHostNetworkString(str, "xlx", m_xlxNetwork); + str += " "; + buildNetworkHostNetworkString(str, "net1", m_dmrNetwork1); + str += " "; + buildNetworkHostNetworkString(str, "net2", m_dmrNetwork2); + str += " "; + buildNetworkHostNetworkString(str, "net3", m_dmrNetwork3); + str += " "; + buildNetworkHostNetworkString(str, "net4", m_dmrNetwork4); + str += " "; + buildNetworkHostNetworkString(str, "net5", m_dmrNetwork5); +} + +void CDMRGateway::buildNetworkHostNetworkString(std::string &str, const std::string& name, CDMRNetwork* network) +{ + if (network && (network == m_xlxNetwork)) { + std::string module = ((m_xlxReflector >= 4001U && m_xlxReflector <= 4026U) ? ("_" + std::string(1, (('A' + (m_xlxReflector % 100U)) - 1U))) : ""); + str += name + ":\"XLX" + std::to_string(m_xlxNumber) + module + "\""; + } else { + std::string host = ((network == NULL) ? "NONE" : network->getName()); + str += name + ":\""+ ((network == NULL) ? "NONE" : ((host.length() > 0) ? host : "NONE")) + "\""; + } +} diff --git a/DMRGateway.h b/DMRGateway.h index fc65671..9fbce2f 100644 --- a/DMRGateway.h +++ b/DMRGateway.h @@ -56,6 +56,7 @@ public: int run(); void buildNetworkStatusString(std::string &str); + void buildNetworkHostsString(std::string &str); private: CConf m_conf; @@ -156,6 +157,7 @@ private: void remoteControl(); void processEnableCommand(CDMRNetwork* network, const std::string& name, bool& mode, bool enabled); void buildNetworkStatusNetworkString(std::string &str, const std::string& name, CDMRNetwork* network, bool enabled); + void buildNetworkHostNetworkString(std::string &str, const std::string& name, CDMRNetwork* network); }; #endif diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 59021c5..c9f8ca5 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -298,6 +298,11 @@ bool CDMRNetwork::isConnected() const return m_status == RUNNING; } +std::string const CDMRNetwork::getName() const +{ + return m_name; +} + void CDMRNetwork::close(bool sayGoodbye) { LogMessage("%s, Closing DMR Network", m_name.c_str()); diff --git a/DMRNetwork.h b/DMRNetwork.h index cf744d3..6af2ce4 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -56,6 +56,7 @@ public: void clock(unsigned int ms); bool isConnected() const; + std::string const getName() const; void close(bool sayGoodbye); diff --git a/RemoteControl.cpp b/RemoteControl.cpp index d4e09e1..8f749cb 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -111,6 +111,15 @@ REMOTE_COMMAND CRemoteControl::getCommand() } m_command = RCD_CONNECTION_STATUS; + } else if (m_args.at(0U) == "hosts") { + if (m_host != NULL) { + m_host->buildNetworkHostsString(replyStr); + } + else { + replyStr = "KO"; + } + + m_command = RCD_CONFIG_HOSTS; } else { replyStr = "KO"; } diff --git a/RemoteControl.h b/RemoteControl.h index 61e5a7a..260cdc8 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -38,6 +38,7 @@ enum REMOTE_COMMAND { RCD_DISABLE_NETWORK5, RCD_DISABLE_XLX, RCD_CONNECTION_STATUS, + RCD_CONFIG_HOSTS, RCD_NONE };