Don't send RPTCL on DMR under error conditions.

This commit is contained in:
Jonathan Naylor 2021-04-08 18:36:27 +01:00
parent 6b43bce561
commit dad34bea98
7 changed files with 16 additions and 16 deletions

View File

@ -321,11 +321,11 @@ bool CDMRDirectNetwork::isConnected() const
return (m_status == RUNNING); return (m_status == RUNNING);
} }
void CDMRDirectNetwork::close() void CDMRDirectNetwork::close(bool sayGoodbye)
{ {
LogMessage("Closing DMR Network"); LogMessage("Closing DMR Network");
if (m_status == RUNNING) { if (sayGoodbye && (m_status == RUNNING)) {
unsigned char buffer[9U]; unsigned char buffer[9U];
::memcpy(buffer + 0U, "RPTCL", 5U); ::memcpy(buffer + 0U, "RPTCL", 5U);
::memcpy(buffer + 5U, m_id, 4U); ::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); int length = m_socket.read(m_buffer, BUFFER_LENGTH, address, addrlen);
if (length < 0) { if (length < 0) {
LogError("DMR, Socket has failed, retrying connection to the master"); LogError("DMR, Socket has failed, retrying connection to the master");
close(); close(false);
open(); open();
return; return;
} }
@ -408,7 +408,7 @@ void CDMRDirectNetwork::clock(unsigned int ms)
the Network sometimes times out and reaches here. the Network sometimes times out and reaches here.
We want it to reconnect so... */ We want it to reconnect so... */
LogError("DMR, Login to the master has failed, retrying network ..."); LogError("DMR, Login to the master has failed, retrying network ...");
close(); close(false);
open(); open();
return; return;
} }
@ -452,7 +452,7 @@ void CDMRDirectNetwork::clock(unsigned int ms)
} }
} else if (::memcmp(m_buffer, "MSTCL", 5U) == 0) { } else if (::memcmp(m_buffer, "MSTCL", 5U) == 0) {
LogError("DMR, Master is closing down"); LogError("DMR, Master is closing down");
close(); close(false);
open(); open();
} else if (::memcmp(m_buffer, "MSTPONG", 7U) == 0) { } else if (::memcmp(m_buffer, "MSTPONG", 7U) == 0) {
m_timeoutTimer.start(); m_timeoutTimer.start();
@ -466,7 +466,7 @@ void CDMRDirectNetwork::clock(unsigned int ms)
m_timeoutTimer.clock(ms); m_timeoutTimer.clock(ms);
if (m_timeoutTimer.isRunning() && m_timeoutTimer.hasExpired()) { if (m_timeoutTimer.isRunning() && m_timeoutTimer.hasExpired()) {
LogError("DMR, Connection to the master has timed out, retrying connection"); LogError("DMR, Connection to the master has timed out, retrying connection");
close(); close(false);
open(); 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); bool ret = m_socket.write(data, length, m_addr, m_addrLen);
if (!ret) { if (!ret) {
LogError("DMR, Socket has failed when writing data to the master, retrying connection"); LogError("DMR, Socket has failed when writing data to the master, retrying connection");
m_socket.close(); close(false);
open(); open();
return false; return false;
} }

View File

@ -57,7 +57,7 @@ public:
virtual bool isConnected() const; virtual bool isConnected() const;
virtual void close(); virtual void close(bool sayGoodbye);
private: private:
std::string m_address; std::string m_address;

View File

@ -292,7 +292,7 @@ bool CDMRGatewayNetwork::isConnected() const
return (m_addrLen != 0); return (m_addrLen != 0);
} }
void CDMRGatewayNetwork::close() void CDMRGatewayNetwork::close(bool sayGoodbye)
{ {
LogMessage("DMR, Closing DMR Network"); LogMessage("DMR, Closing DMR Network");

View File

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -58,7 +58,7 @@ public:
virtual bool isConnected() const; virtual bool isConnected() const;
virtual void close(); virtual void close(bool sayGoodbye);
private: private:
std::string m_addressStr; std::string m_addressStr;

View File

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -50,7 +50,7 @@ public:
virtual bool isConnected() const = 0; virtual bool isConnected() const = 0;
virtual void close() = 0; virtual void close(bool sayGoodbye) = 0;
private: private:
}; };

View File

@ -1118,7 +1118,7 @@ int CMMDVMHost::run()
} }
if (m_dmrNetwork != NULL) { if (m_dmrNetwork != NULL) {
m_dmrNetwork->close(); m_dmrNetwork->close(true);
delete m_dmrNetwork; delete m_dmrNetwork;
} }

View File

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20210312"; const char* VERSION = "20210408";
#endif #endif