mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-20 21:25:37 +08:00
Implement remote command support.
- Defaut port is 7643 (totally arbitrary)
- Using RemoteCommandDMRG, each network can be enabled or disabled (net1 .. net5, xlx):
~ $ RemoteCommandDMRG 7643 disable net2
M: 2021-03-20 11:48:40.494 Command sent: "disable net2" to port: 7643
M: 2021-03-20 11:48:40.545 OK
- Using RemoteCommandDMRG, a connection status can be retrieved:
~ $ RemoteCommandDMRG 7643 status
M: 2021-03-20 11:49:13.513 Command sent: "status" to port: 7643
M: 2021-03-20 11:49:13.563 xlx:conn net1:conn net2:n/a net3:n/a net4:conn net5:n/a
A returned string is expected from the socket connection, this is why I did not reuse the MMDVMHost's RemoteCommand (unless MMDVMHost RemoteControl is modified as well).
The exit value can be used in scripting (also 1 if we didn't get any reply).
This commit is contained in:
32
Conf.cpp
32
Conf.cpp
@@ -40,7 +40,8 @@ enum SECTION {
|
||||
SECTION_XLX_NETWORK,
|
||||
SECTION_GPSD,
|
||||
SECTION_APRS,
|
||||
SECTION_DYNAMIC_TG_CONTROL
|
||||
SECTION_DYNAMIC_TG_CONTROL,
|
||||
SECTION_REMOTE_CONTROL
|
||||
};
|
||||
|
||||
CConf::CConf(const std::string& file) :
|
||||
@@ -182,7 +183,10 @@ m_aprsPort(0U),
|
||||
m_aprsSuffix(),
|
||||
m_aprsDescription(),
|
||||
m_dynamicTGControlEnabled(false),
|
||||
m_dynamicTGControlPort(3769U)
|
||||
m_dynamicTGControlPort(3769U),
|
||||
m_remoteControlEnabled(false),
|
||||
m_remoteControlAddress("127.0.0.1"),
|
||||
m_remoteControlPort(0U)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -232,6 +236,8 @@ bool CConf::read()
|
||||
section = SECTION_APRS;
|
||||
else if (::strncmp(buffer, "[Dynamic TG Control]", 20U) == 0)
|
||||
section = SECTION_DYNAMIC_TG_CONTROL;
|
||||
else if (::strncmp(buffer, "[Remote Control]", 16U) == 0)
|
||||
section = SECTION_REMOTE_CONTROL;
|
||||
else
|
||||
section = SECTION_NONE;
|
||||
|
||||
@@ -977,6 +983,13 @@ bool CConf::read()
|
||||
m_dynamicTGControlEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_dynamicTGControlPort = (unsigned int)::atoi(value);
|
||||
} else if (section == SECTION_REMOTE_CONTROL) {
|
||||
if (::strcmp(key, "Enable") == 0)
|
||||
m_remoteControlEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_remoteControlAddress = value;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_remoteControlPort = (unsigned int)::atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1687,3 +1700,18 @@ unsigned int CConf::getDynamicTGControlPort() const
|
||||
{
|
||||
return m_dynamicTGControlPort;
|
||||
}
|
||||
|
||||
bool CConf::getRemoteControlEnabled() const
|
||||
{
|
||||
return m_remoteControlEnabled;
|
||||
}
|
||||
|
||||
std::string CConf::getRemoteControlAddress() const
|
||||
{
|
||||
return m_remoteControlAddress;
|
||||
}
|
||||
|
||||
unsigned int CConf::getRemoteControlPort() const
|
||||
{
|
||||
return m_remoteControlPort;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user