rework remote IP modem control;

pull/12/head
Bryan Biedenkapp 4 years ago
parent 48ff042668
commit aeb54095bc

@ -130,10 +130,6 @@ typedef unsigned long long ulong64_t;
#define NULL_PORT "null"
#define UART_PORT "uart"
#define PTY_PORT "pty"
#define UDP_PORT "udp"
#define UDP_MODE_MASTER "master"
#define UDP_MODE_PEER "peer"
const uint32_t REMOTE_MODEM_PORT = 3334;
const uint32_t TRAFFIC_DEFAULT_PORT = 62031;

@ -91,6 +91,10 @@ std::string g_lockFile = std::string(DEFAULT_LOCK_FILE);
bool g_foreground = false;
bool g_killed = false;
bool g_remoteModemMode = false;
std::string g_remoteAddress = std::string("127.0.0.1");
uint16_t g_remotePort = REMOTE_MODEM_PORT;
bool g_fireDMRBeacon = false;
bool g_fireP25Control = false;
bool g_fireNXDNControl = false;
@ -136,11 +140,15 @@ void usage(const char* message, const char* arg)
::fprintf(stderr, "\n\n");
}
::fprintf(stdout, "usage: %s [-v] [-f] [--cal] [--setup] [-c <configuration file>]\n\n"
::fprintf(stdout, "usage: %s [-v] [-f] [--cal] [--setup] [-c <configuration file>] [--remote [-a <address>] [-p <port>]]\n\n"
" -f foreground mode\n"
" --cal calibration mode\n"
" --setup setup mode\n"
"\n"
" --remote remote modem mode\n"
" -a remote modem command address\n"
" -p remote modem command port\n"
"\n"
" -v show version information\n"
" -h show this screen\n"
" -- stop handling options\n",
@ -185,6 +193,29 @@ int checkArgs(int argc, char* argv[])
p += 2;
}
else if (IS("--remote")) {
g_remoteModemMode = true;
}
else if (IS("-a")) {
if ((argc - 1) <= 0)
usage("error: %s", "must specify the address to connect to");
g_remoteAddress = std::string(argv[++i]);
if (g_remoteAddress == "")
usage("error: %s", "remote address cannot be blank!");
p += 2;
}
else if (IS("-p")) {
if ((argc - 1) <= 0)
usage("error: %s", "must specify the port to connect to");
g_remotePort = (uint16_t)::atoi(argv[++i]);
if (g_remotePort == 0)
usage("error: %s", "remote port number cannot be blank or 0!");
p += 2;
}
else if (IS("-v")) {
::fprintf(stdout, __PROG_NAME__ " %s (" DESCR_DMR DESCR_P25 DESCR_NXDN "CW Id, Network) (built %s)\n", __VER__, __BUILD__);
::fprintf(stdout, "Copyright (c) 2017-2022 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\n");

@ -47,6 +47,10 @@ extern std::string g_lockFile;
extern bool g_foreground;
extern bool g_killed;
extern bool g_remoteModemMode;
extern std::string g_remoteAddress;
extern uint16_t g_remotePort;
extern bool g_fireDMRBeacon;
extern bool g_fireP25Control;
extern bool g_fireNXDNControl;

@ -130,14 +130,10 @@ system:
siteId: 1
modem:
protocol:
type: "null" # Valid values are "null", "uart", and "udp"
type: "null" # Valid values are "null", and "uart"
uart:
port: /dev/ttyUSB0
speed: 115200
udp:
mode: master # Valid values are "master", and "peer"
endpointAddress: 0.0.0.0
port: 3334
rxInvert: false
txInvert: false
pttInvert: false

@ -1738,7 +1738,7 @@ bool Host::readParams()
bool udpMasterMode = false;
std::transform(portType.begin(), portType.end(), portType.begin(), ::tolower);
if (portType == UDP_PORT && udpMode == UDP_MODE_MASTER) {
if ((portType == UART_PORT || portType == PTY_PORT) && g_remoteModemMode) {
udpMasterMode = true;
}
@ -1987,11 +1987,6 @@ bool Host::createModem()
std::string uartPort = uartProtocol["port"].as<std::string>();
uint32_t uartSpeed = uartProtocol["speed"].as<uint32_t>(115200);
yaml::Node udpProtocol = modemProtocol["udp"];
std::string udpMode = udpProtocol["mode"].as<std::string>("master");
std::string udpAddress = udpProtocol["endpointAddress"].as<std::string>();
uint16_t udpPort = (uint16_t)udpProtocol["port"].as<uint32_t>(REMOTE_MODEM_PORT);
bool rxInvert = modemConf["rxInvert"].as<bool>(false);
bool txInvert = modemConf["txInvert"].as<bool>(false);
bool pttInvert = modemConf["pttInvert"].as<bool>(false);
@ -2068,7 +2063,7 @@ bool Host::createModem()
if (portType == NULL_PORT) {
modemPort = new port::ModemNullPort();
}
else if (portType == UART_PORT || portType == UDP_PORT || portType == PTY_PORT) {
else if (portType == UART_PORT || portType == PTY_PORT) {
port::SERIAL_SPEED serialSpeed = port::SERIAL_115200;
switch (uartSpeed) {
case 1200:
@ -2126,25 +2121,21 @@ bool Host::createModem()
return false;
}
if (portType == UDP_PORT) {
std::transform(udpMode.begin(), udpMode.end(), udpMode.begin(), ::tolower);
if (udpMode == UDP_MODE_MASTER) {
m_modemRemotePort = new port::UDPPort(udpAddress, udpPort);
if (g_remoteModemMode) {
if (portType == UART_PORT || portType == PTY_PORT) {
m_modemRemotePort = new port::UDPPort(g_remoteAddress, g_remotePort);
m_modemRemote = true;
}
else if (udpMode == UDP_MODE_PEER) {
else {
delete modemPort;
modemPort = new port::UDPPort(udpAddress, udpPort);
modemPort = new port::UDPPort(g_remoteAddress, g_remotePort);
m_modemRemote = false;
}
else {
LogError(LOG_HOST, "Invalid UDP mode, %s!", udpMode.c_str());
return false;
}
LogInfo(" UDP Mode: %s", udpMode.c_str());
LogInfo(" UDP Address: %s", udpAddress.c_str());
LogInfo(" UDP Port: %u", udpPort);
LogInfo(" UDP Mode: %s", m_modemRemote ? "master" : "peer");
LogInfo(" UDP Address: %s", g_remoteAddress.c_str());
LogInfo(" UDP Port: %u", g_remotePort);
}
LogInfo(" RX Invert: %s", rxInvert ? "yes" : "no");

@ -430,7 +430,7 @@ int HostCal::run()
LogInfo(" Ignore Modem Configuration Area: yes");
}
}
else if (portType == UDP_PORT) {
else if (g_remoteModemMode) {
::LogError(LOG_HOST, "Calibration mode is unsupported with a remote modem!");
return 2;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.