Skip to content

Commit

Permalink
Don't send RPTCL on DMR under error conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Apr 8, 2021
1 parent 6b43bce commit dad34be
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions DMRDirectNetwork.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion DMRDirectNetwork.h
Expand Up @@ -57,7 +57,7 @@ class CDMRDirectNetwork : public IDMRNetwork

virtual bool isConnected() const;

virtual void close();
virtual void close(bool sayGoodbye);

private:
std::string m_address;
Expand Down
2 changes: 1 addition & 1 deletion DMRGatewayNetwork.cpp
Expand Up @@ -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");

Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down Expand Up @@ -58,7 +58,7 @@ class CDMRGatewayNetwork : public IDMRNetwork

virtual bool isConnected() const;

virtual void close();
virtual void close(bool sayGoodbye);

private:
std::string m_addressStr;
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down Expand Up @@ -50,7 +50,7 @@ class IDMRNetwork

virtual bool isConnected() const = 0;

virtual void close() = 0;
virtual void close(bool sayGoodbye) = 0;

private:
};
Expand Down
2 changes: 1 addition & 1 deletion MMDVMHost.cpp
Expand Up @@ -1118,7 +1118,7 @@ int CMMDVMHost::run()
}

if (m_dmrNetwork != NULL) {
m_dmrNetwork->close();
m_dmrNetwork->close(true);
delete m_dmrNetwork;
}

Expand Down
4 changes: 2 additions & 2 deletions 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
Expand All @@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H

const char* VERSION = "20210312";
const char* VERSION = "20210408";

#endif

0 comments on commit dad34be

Please sign in to comment.