diff --git a/DMRDirectNetwork.cpp b/DMRDirectNetwork.cpp index c5013dde..d8c34fe1 100644 --- a/DMRDirectNetwork.cpp +++ b/DMRDirectNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018,2020,2021,2024 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 @@ -72,6 +72,9 @@ m_beacon(false) assert(id > 1000U); assert(!password.empty()); + if (CUDPSocket::lookup(m_address, m_port, m_addr, m_addrLen) != 0) + m_addrLen = 0U; + m_buffer = new unsigned char[BUFFER_LENGTH]; m_salt = new unsigned char[sizeof(uint32_t)]; m_id = new uint8_t[4U]; @@ -121,18 +124,18 @@ void CDMRDirectNetwork::setConfig(const std::string& callsign, unsigned int rxFr bool CDMRDirectNetwork::open() { - if (CUDPSocket::lookup(m_address, m_port, m_addr, m_addrLen) != 0) { + if (m_addrLen == 0U) { LogError("DMR, Could not lookup the address of the DMR Network"); return false; } - LogMessage("Opening DMR Network"); + LogMessage("DMR, Opening DMR Network"); m_status = WAITING_CONNECT; m_timeoutTimer.stop(); m_retryTimer.start(); - return true; + return m_socket.open(m_addr); } void CDMRDirectNetwork::enable(bool enabled) @@ -323,7 +326,7 @@ bool CDMRDirectNetwork::isConnected() const void CDMRDirectNetwork::close(bool sayGoodbye) { - LogMessage("Closing DMR Network"); + LogMessage("DMR, Closing DMR Network"); if (sayGoodbye && (m_status == RUNNING)) { unsigned char buffer[9U]; @@ -344,11 +347,8 @@ void CDMRDirectNetwork::clock(unsigned int ms) if (m_retryTimer.isRunning() && m_retryTimer.hasExpired()) { switch (m_status) { case WAITING_CONNECT: - if (m_socket.open(m_addr)) { - if (writeLogin()) { - m_status = WAITING_LOGIN; - } - } + writeLogin(); + m_status = WAITING_LOGIN; break; case WAITING_LOGIN: writeLogin(); diff --git a/DMRGatewayNetwork.cpp b/DMRGatewayNetwork.cpp index 5dd55b51..1eb7e634 100644 --- a/DMRGatewayNetwork.cpp +++ b/DMRGatewayNetwork.cpp @@ -105,7 +105,7 @@ void CDMRGatewayNetwork::setOptions(const std::string& options) bool CDMRGatewayNetwork::open() { if (m_addrLen == 0U) { - LogError("Unable to resolve the address of the DMR Network"); + LogError("DMR, Unable to resolve the address of the DMR Network"); return false; } diff --git a/POCSAGNetwork.cpp b/POCSAGNetwork.cpp index 2a4e6504..f8bd0730 100644 --- a/POCSAGNetwork.cpp +++ b/POCSAGNetwork.cpp @@ -53,7 +53,7 @@ bool CPOCSAGNetwork::open() LogMessage("Opening POCSAG network connection"); - return m_socket.open(); + return m_socket.open(m_addr); } void CPOCSAGNetwork::clock(unsigned int ms) diff --git a/RemoteControl.cpp b/RemoteControl.cpp index e9f54292..f88f15db 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2019,2020,2021,2024 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 @@ -36,10 +36,15 @@ const unsigned int BUFFER_LENGTH = 100U; CRemoteControl::CRemoteControl(CMMDVMHost *host, const std::string address, unsigned int port) : m_host(host), m_socket(address, port), +m_addr(), +m_addrLen(0U), m_command(RCD_NONE), m_args() { assert(port > 0U); + + if (CUDPSocket::lookup(address, port, m_addr, m_addrLen) != 0) + m_addrLen = 0U; } CRemoteControl::~CRemoteControl() @@ -48,7 +53,12 @@ CRemoteControl::~CRemoteControl() bool CRemoteControl::open() { - return m_socket.open(); + if (m_addrLen == 0U) { + LogError("Unable to resolve the address of the remote control port"); + return false; + } + + return m_socket.open(m_addr); } REMOTE_COMMAND CRemoteControl::getCommand() diff --git a/RemoteControl.h b/RemoteControl.h index a4b28858..61d05163 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2019,2020,2021,2024 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 @@ -83,6 +83,8 @@ class CRemoteControl { private: CMMDVMHost* m_host; CUDPSocket m_socket; + sockaddr_storage m_addr; + unsigned int m_addrLen; REMOTE_COMMAND m_command; std::vector m_args; }; diff --git a/Version.h b/Version.h index ba845b1c..a4e820a5 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20240129"; +const char* VERSION = "20240201"; #endif