mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-20 21:25:37 +08:00
Add new remote command:
- hosts: display connected hosts, or NONE if disconnected (surrounded with double quotes).
This commit is contained in:
@@ -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")) + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
void clock(unsigned int ms);
|
||||
|
||||
bool isConnected() const;
|
||||
std::string const getName() const;
|
||||
|
||||
void close(bool sayGoodbye);
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ enum REMOTE_COMMAND {
|
||||
RCD_DISABLE_NETWORK5,
|
||||
RCD_DISABLE_XLX,
|
||||
RCD_CONNECTION_STATUS,
|
||||
RCD_CONFIG_HOSTS,
|
||||
RCD_NONE
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user