forked from g4klx/MMDVMHost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Naylor
committed
Jan 7, 2019
1 parent
5de3bee
commit 42a4820
Showing
15 changed files
with
187 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,3 +252,6 @@ Enable=0 | |
Address=127.0.0.1 | ||
Port=7834 | ||
|
||
[Remote Control] | ||
Enable=0 | ||
Port=7642 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |