From dad34bea987a539adced43bde14b726fba2b0ae3 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 8 Apr 2021 18:36:27 +0100 Subject: [PATCH] Don't send RPTCL on DMR under error conditions. --- DMRDirectNetwork.cpp | 14 +++++++------- DMRDirectNetwork.h | 2 +- DMRGatewayNetwork.cpp | 2 +- DMRGatewayNetwork.h | 4 ++-- DMRNetwork.h | 4 ++-- MMDVMHost.cpp | 2 +- Version.h | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/DMRDirectNetwork.cpp b/DMRDirectNetwork.cpp index a378f7a..a27a646 100644 --- a/DMRDirectNetwork.cpp +++ b/DMRDirectNetwork.cpp @@ -321,11 +321,11 @@ bool CDMRDirectNetwork::isConnected() const return (m_status == RUNNING); } -void CDMRDirectNetwork::close() +void CDMRDirectNetwork::close(bool sayGoodbye) { LogMessage("Closing DMR Network"); - if (m_status == RUNNING) { + if (sayGoodbye && (m_status == RUNNING)) { unsigned char buffer[9U]; ::memcpy(buffer + 0U, "RPTCL", 5U); ::memcpy(buffer + 5U, m_id, 4U); @@ -377,7 +377,7 @@ void CDMRDirectNetwork::clock(unsigned int ms) int length = m_socket.read(m_buffer, BUFFER_LENGTH, address, addrlen); if (length < 0) { LogError("DMR, Socket has failed, retrying connection to the master"); - close(); + close(false); open(); return; } @@ -408,7 +408,7 @@ void CDMRDirectNetwork::clock(unsigned int ms) the Network sometimes times out and reaches here. We want it to reconnect so... */ LogError("DMR, Login to the master has failed, retrying network ..."); - close(); + close(false); open(); return; } @@ -452,7 +452,7 @@ void CDMRDirectNetwork::clock(unsigned int ms) } } else if (::memcmp(m_buffer, "MSTCL", 5U) == 0) { LogError("DMR, Master is closing down"); - close(); + close(false); open(); } else if (::memcmp(m_buffer, "MSTPONG", 7U) == 0) { m_timeoutTimer.start(); @@ -466,7 +466,7 @@ void CDMRDirectNetwork::clock(unsigned int ms) m_timeoutTimer.clock(ms); if (m_timeoutTimer.isRunning() && m_timeoutTimer.hasExpired()) { LogError("DMR, Connection to the master has timed out, retrying connection"); - close(); + close(false); open(); } } @@ -635,7 +635,7 @@ bool CDMRDirectNetwork::write(const unsigned char* data, unsigned int length) bool ret = m_socket.write(data, length, m_addr, m_addrLen); if (!ret) { LogError("DMR, Socket has failed when writing data to the master, retrying connection"); - m_socket.close(); + close(false); open(); return false; } diff --git a/DMRDirectNetwork.h b/DMRDirectNetwork.h index f6e0834..6df82cc 100644 --- a/DMRDirectNetwork.h +++ b/DMRDirectNetwork.h @@ -57,7 +57,7 @@ public: virtual bool isConnected() const; - virtual void close(); + virtual void close(bool sayGoodbye); private: std::string m_address; diff --git a/DMRGatewayNetwork.cpp b/DMRGatewayNetwork.cpp index 775a79d..f6dfe47 100644 --- a/DMRGatewayNetwork.cpp +++ b/DMRGatewayNetwork.cpp @@ -292,7 +292,7 @@ bool CDMRGatewayNetwork::isConnected() const return (m_addrLen != 0); } -void CDMRGatewayNetwork::close() +void CDMRGatewayNetwork::close(bool sayGoodbye) { LogMessage("DMR, Closing DMR Network"); diff --git a/DMRGatewayNetwork.h b/DMRGatewayNetwork.h index bc00385..7bca94f 100644 --- a/DMRGatewayNetwork.h +++ b/DMRGatewayNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018,2020,2021 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 @@ -58,7 +58,7 @@ public: virtual bool isConnected() const; - virtual void close(); + virtual void close(bool sayGoodbye); private: std::string m_addressStr; diff --git a/DMRNetwork.h b/DMRNetwork.h index 4a3c4d7..006e097 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018,2020,2021 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 @@ -50,7 +50,7 @@ public: virtual bool isConnected() const = 0; - virtual void close() = 0; + virtual void close(bool sayGoodbye) = 0; private: }; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8409aac..ab8b5b1 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1118,7 +1118,7 @@ int CMMDVMHost::run() } if (m_dmrNetwork != NULL) { - m_dmrNetwork->close(); + m_dmrNetwork->close(true); delete m_dmrNetwork; } diff --git a/Version.h b/Version.h index 6e4502f..486d545 100644 --- a/Version.h +++ b/Version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2021 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 @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210312"; +const char* VERSION = "20210408"; #endif