Merge branch 'master' into M17_AX25_FM

This commit is contained in:
Jonathan Naylor 2021-04-08 18:44:51 +01:00
commit e6d5ef9055
12 changed files with 25 additions and 23 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

@ -289,10 +289,10 @@ bool CDMRGatewayNetwork::writeTalkerAlias(unsigned int id, unsigned char type, c
bool CDMRGatewayNetwork::isConnected() const bool CDMRGatewayNetwork::isConnected() const
{ {
return (m_enabled && (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

@ -316,7 +316,7 @@ void CDStarNetwork::reset()
bool CDStarNetwork::isConnected() const bool CDStarNetwork::isConnected() const
{ {
return (m_enabled && (m_addrLen != 0)); return (m_addrLen != 0);
} }
void CDStarNetwork::close() void CDStarNetwork::close()

View file

@ -1260,7 +1260,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

@ -155,7 +155,7 @@ void CNXDNIcomNetwork::reset()
bool CNXDNIcomNetwork::isConnected() const bool CNXDNIcomNetwork::isConnected() const
{ {
return (m_enabled && (m_addrLen != 0)); return (m_addrLen != 0);
} }
void CNXDNIcomNetwork::close() void CNXDNIcomNetwork::close()

View file

@ -837,7 +837,7 @@ void CNXDNKenwoodNetwork::reset()
bool CNXDNKenwoodNetwork::isConnected() const bool CNXDNKenwoodNetwork::isConnected() const
{ {
return (m_enabled && (m_rtcpAddrLen != 0U) && (m_rtpAddrLen != 0U)); return ((m_rtcpAddrLen != 0U) && (m_rtpAddrLen != 0U));
} }
void CNXDNKenwoodNetwork::close() void CNXDNKenwoodNetwork::close()

View file

@ -426,7 +426,7 @@ unsigned int CP25Network::read(unsigned char* data, unsigned int length)
bool CP25Network::isConnected() const bool CP25Network::isConnected() const
{ {
return (m_enabled && (m_addrLen != 0)); return (m_addrLen != 0);
} }
void CP25Network::close() void CP25Network::close()

View file

@ -188,6 +188,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false; return false;
} }
close(index);
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0); int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
if (fd < 0) { if (fd < 0) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
@ -344,13 +346,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
void CUDPSocket::close() void CUDPSocket::close()
{ {
for (int i = 0; i < UDP_SOCKET_MAX; i++) for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
close(m_fd[i]); close(i);
} }
void CUDPSocket::close(const unsigned int index) void CUDPSocket::close(const unsigned int index)
{ {
if (m_fd[index] >= 0) { if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
::closesocket(m_fd[index]); ::closesocket(m_fd[index]);
#else #else

View file

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20210407"; const char* VERSION = "20210408";
#endif #endif