diff --git a/Conf.cpp b/Conf.cpp index 9325a1b..e365827 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -250,6 +250,7 @@ m_mobileGPSEnabled(false), m_mobileGPSAddress(), m_mobileGPSPort(0U), m_remoteControlEnabled(false), +m_remoteControlAddress("127.0.0.1"), m_remoteControlPort(0U) { } @@ -838,6 +839,8 @@ bool CConf::read() } 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); } @@ -1794,6 +1797,11 @@ bool CConf::getRemoteControlEnabled() const return m_remoteControlEnabled; } +std::string CConf::getRemoteControlAddress() const +{ + return m_remoteControlAddress; +} + unsigned int CConf::getRemoteControlPort() const { return m_remoteControlPort; diff --git a/Conf.h b/Conf.h index c76b202..42fa261 100644 --- a/Conf.h +++ b/Conf.h @@ -276,6 +276,7 @@ public: // The Remote Control section bool getRemoteControlEnabled() const; + std::string getRemoteControlAddress() const; unsigned int getRemoteControlPort() const; private: @@ -497,6 +498,7 @@ private: unsigned int m_mobileGPSPort; bool m_remoteControlEnabled; + std::string m_remoteControlAddress; unsigned int m_remoteControlPort; }; diff --git a/MMDVM.ini b/MMDVM.ini index d6a8d84..bf07c6a 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -257,4 +257,5 @@ Port=7834 [Remote Control] Enable=0 +Address=127.0.0.1 Port=7642 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9f792e5..5ee837a 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -606,12 +606,14 @@ int CMMDVMHost::run() bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); if (remoteControlEnabled) { + std::string address = m_conf.getRemoteControlAddress(); unsigned int port = m_conf.getRemoteControlPort(); LogInfo("Remote Control Parameters"); + LogInfo(" Address: %s", address.c_str()); LogInfo(" Port: %u", port); - m_remoteControl = new CRemoteControl(port); + m_remoteControl = new CRemoteControl(address, port); ret = m_remoteControl->open(); if (!ret) { diff --git a/RemoteControl.cpp b/RemoteControl.cpp index 0c29791..e982894 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -29,8 +29,8 @@ const unsigned int PAGE_ARGS = 3U; const unsigned int BUFFER_LENGTH = 100U; -CRemoteControl::CRemoteControl(unsigned int port) : -m_socket(port), +CRemoteControl::CRemoteControl(const std::string address, unsigned int port) : +m_socket(address, port), m_command(RCD_NONE), m_args() { @@ -43,7 +43,7 @@ CRemoteControl::~CRemoteControl() bool CRemoteControl::open() { - return m_socket.open(AF_INET); /* XXX IPv4 only */ + return m_socket.open(); } REMOTE_COMMAND CRemoteControl::getCommand() diff --git a/RemoteControl.h b/RemoteControl.h index 479987a..079d983 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -38,7 +38,7 @@ enum REMOTE_COMMAND { class CRemoteControl { public: - CRemoteControl(unsigned int port); + CRemoteControl(const std::string address, unsigned int port); ~CRemoteControl(); bool open();