Add remote control interface.
This commit is contained in:
parent
5de3beef61
commit
42a48209d4
15 changed files with 187 additions and 12 deletions
25
Conf.cpp
25
Conf.cpp
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015-2019 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -56,7 +56,8 @@ enum SECTION {
|
|||
SECTION_OLED,
|
||||
SECTION_LCDPROC,
|
||||
SECTION_LOCK_FILE,
|
||||
SECTION_MOBILE_GPS
|
||||
SECTION_MOBILE_GPS,
|
||||
SECTION_REMOTE_CONTROL
|
||||
};
|
||||
|
||||
CConf::CConf(const std::string& file) :
|
||||
|
@ -246,7 +247,9 @@ m_lockFileEnabled(false),
|
|||
m_lockFileName(),
|
||||
m_mobileGPSEnabled(false),
|
||||
m_mobileGPSAddress(),
|
||||
m_mobileGPSPort(0U)
|
||||
m_mobileGPSPort(0U),
|
||||
m_remoteControlEnabled(false),
|
||||
m_remoteControlPort(0U)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -326,6 +329,8 @@ bool CConf::read()
|
|||
section = SECTION_LOCK_FILE;
|
||||
else if (::strncmp(buffer, "[Mobile GPS]", 12U) == 0)
|
||||
section = SECTION_MOBILE_GPS;
|
||||
else if (::strncmp(buffer, "[Remote Control]", 16U) == 0)
|
||||
section = SECTION_REMOTE_CONTROL;
|
||||
else
|
||||
section = SECTION_NONE;
|
||||
|
||||
|
@ -813,6 +818,11 @@ bool CConf::read()
|
|||
m_mobileGPSAddress = value;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_mobileGPSPort = (unsigned int)::atoi(value);
|
||||
} else if (section == SECTION_REMOTE_CONTROL) {
|
||||
if (::strcmp(key, "Enable") == 0)
|
||||
m_remoteControlEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_remoteControlPort = (unsigned int)::atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1756,3 +1766,12 @@ unsigned int CConf::getMobileGPSPort() const
|
|||
return m_mobileGPSPort;
|
||||
}
|
||||
|
||||
bool CConf::getRemoteControlEnabled() const
|
||||
{
|
||||
return m_remoteControlEnabled;
|
||||
}
|
||||
|
||||
unsigned int CConf::getRemoteControlPort() const
|
||||
{
|
||||
return m_remoteControlPort;
|
||||
}
|
||||
|
|
9
Conf.h
9
Conf.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015-2019 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -273,6 +273,10 @@ public:
|
|||
std::string getMobileGPSAddress() const;
|
||||
unsigned int getMobileGPSPort() const;
|
||||
|
||||
// The Remote Control section
|
||||
bool getRemoteControlEnabled() const;
|
||||
unsigned int getRemoteControlPort() const;
|
||||
|
||||
private:
|
||||
std::string m_file;
|
||||
std::string m_callsign;
|
||||
|
@ -489,6 +493,9 @@ private:
|
|||
bool m_mobileGPSEnabled;
|
||||
std::string m_mobileGPSAddress;
|
||||
unsigned int m_mobileGPSPort;
|
||||
|
||||
bool m_remoteControlEnabled;
|
||||
unsigned int m_remoteControlPort;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -252,3 +252,6 @@ Enable=0
|
|||
Address=127.0.0.1
|
||||
Port=7834
|
||||
|
||||
[Remote Control]
|
||||
Enable=0
|
||||
Port=7642
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015-2019 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include "P25Control.h"
|
||||
#include "NXDNControl.h"
|
||||
#include "POCSAGControl.h"
|
||||
#include "RemoteControl.h"
|
||||
#include "Thread.h"
|
||||
#include "Log.h"
|
||||
#include "GitVersion.h"
|
||||
|
@ -582,6 +583,23 @@ int CMMDVMHost::run()
|
|||
pocsagTimer.start();
|
||||
}
|
||||
|
||||
CRemoteControl* remoteControl = NULL;
|
||||
bool remoteControlEnabled = m_conf.getRemoteControlEnabled();
|
||||
if (remoteControlEnabled) {
|
||||
unsigned int port = m_conf.getRemoteControlPort();
|
||||
|
||||
LogInfo("Remote Control Parameters");
|
||||
LogInfo(" Port; %u", port);
|
||||
|
||||
remoteControl = new CRemoteControl(port);
|
||||
|
||||
ret = remoteControl->open();
|
||||
if (!ret) {
|
||||
delete remoteControl;
|
||||
remoteControl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
setMode(MODE_IDLE);
|
||||
|
||||
LogMessage("MMDVMHost-%s is running", VERSION);
|
||||
|
@ -908,6 +926,17 @@ int CMMDVMHost::run()
|
|||
m_modem->writeTransparentData(data, len);
|
||||
}
|
||||
|
||||
if (remoteControl != NULL) {
|
||||
REMOTE_COMMAND command = remoteControl->getCommand();
|
||||
switch(command) {
|
||||
case RC_FORCE_IDLE:
|
||||
setMode(MODE_IDLE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int ms = stopWatch.elapsed();
|
||||
stopWatch.start();
|
||||
|
||||
|
@ -1051,6 +1080,11 @@ int CMMDVMHost::run()
|
|||
delete transparentSocket;
|
||||
}
|
||||
|
||||
if (remoteControl != NULL) {
|
||||
remoteControl->close();
|
||||
delete remoteControl;
|
||||
}
|
||||
|
||||
delete dstar;
|
||||
delete dmr;
|
||||
delete ysf;
|
||||
|
|
|
@ -220,6 +220,7 @@
|
|||
<ClInclude Include="POCSAGDefines.h" />
|
||||
<ClInclude Include="POCSAGNetwork.h" />
|
||||
<ClInclude Include="QR1676.h" />
|
||||
<ClInclude Include="RemoteControl.h" />
|
||||
<ClInclude Include="RingBuffer.h" />
|
||||
<ClInclude Include="RS129.h" />
|
||||
<ClInclude Include="RS241213.h" />
|
||||
|
@ -308,6 +309,7 @@
|
|||
<ClCompile Include="POCSAGControl.cpp" />
|
||||
<ClCompile Include="POCSAGNetwork.cpp" />
|
||||
<ClCompile Include="QR1676.cpp" />
|
||||
<ClCompile Include="RemoteControl.cpp" />
|
||||
<ClCompile Include="RS129.cpp" />
|
||||
<ClCompile Include="RS241213.cpp" />
|
||||
<ClCompile Include="RSSIInterpolator.cpp" />
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
<ClInclude Include="QR1676.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RingBuffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -331,6 +334,9 @@
|
|||
<ClCompile Include="QR1676.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RS129.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o \
|
||||
NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o \
|
||||
POCSAGControl.o POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o \
|
||||
POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o \
|
||||
Thread.o Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o \
|
||||
NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o \
|
||||
UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o \
|
||||
NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o \
|
||||
NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o OLED.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o \
|
||||
NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \
|
||||
NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o \
|
||||
NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = \
|
|||
DStarSlowData.o Golay2087.o Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o \
|
||||
NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o \
|
||||
NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o \
|
||||
QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
|
||||
QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
|
||||
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
|
|
60
RemoteControl.cpp
Normal file
60
RemoteControl.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "RemoteControl.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
const unsigned int BUFFER_LENGTH = 100U;
|
||||
|
||||
CRemoteControl::CRemoteControl(unsigned int port) :
|
||||
m_socket(port)
|
||||
{
|
||||
assert(port > 0U);
|
||||
}
|
||||
|
||||
CRemoteControl::~CRemoteControl()
|
||||
{
|
||||
}
|
||||
|
||||
bool CRemoteControl::open()
|
||||
{
|
||||
return m_socket.open();
|
||||
}
|
||||
|
||||
REMOTE_COMMAND CRemoteControl::getCommand()
|
||||
{
|
||||
REMOTE_COMMAND command = RC_NONE;
|
||||
|
||||
unsigned char buffer[BUFFER_LENGTH];
|
||||
in_addr address;
|
||||
unsigned int port;
|
||||
int ret = m_socket.read(buffer, BUFFER_LENGTH, address, port);
|
||||
if (ret > 0) {
|
||||
if (::memcmp(buffer, "0", 1U) == 0)
|
||||
command = RC_FORCE_IDLE;
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
void CRemoteControl::close()
|
||||
{
|
||||
m_socket.close();
|
||||
}
|
44
RemoteControl.h
Normal file
44
RemoteControl.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef RemoteControl_H
|
||||
#define RemoteControl_H
|
||||
|
||||
#include "UDPSocket.h"
|
||||
|
||||
enum REMOTE_COMMAND {
|
||||
RC_NONE,
|
||||
RC_FORCE_IDLE
|
||||
};
|
||||
|
||||
class CRemoteControl {
|
||||
public:
|
||||
CRemoteControl(unsigned int port);
|
||||
~CRemoteControl();
|
||||
|
||||
bool open();
|
||||
|
||||
REMOTE_COMMAND getCommand();
|
||||
|
||||
void close();
|
||||
|
||||
private:
|
||||
CUDPSocket m_socket;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue