From b31bc5f8a79525818f94504af4a6811c4978de19 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 9 Mar 2021 21:29:48 +0000 Subject: [PATCH] Improve the logging of the Icom and Kenwood networking. --- NXDNReflector/IcomNetwork.cpp | 12 +++++++++--- NXDNReflector/KenwoodNetwork.cpp | 11 +++++++---- NXDNReflector/NXDNReflector.cpp | 16 ++++++++++------ NXDNReflector/Version.h | 2 +- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/NXDNReflector/IcomNetwork.cpp b/NXDNReflector/IcomNetwork.cpp index 93a1ceb..7404e36 100644 --- a/NXDNReflector/IcomNetwork.cpp +++ b/NXDNReflector/IcomNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,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 @@ -51,9 +51,15 @@ bool CIcomNetwork::open() return false; } - LogMessage("Opening Icom network connection"); + bool ret = m_socket.open(m_addr); + if (!ret) { + LogError("Unable to open the Icom network connection"); + return false; + } - return m_socket.open(m_addr); + LogMessage("Opened the Icom network connection"); + + return true; } bool CIcomNetwork::write(const unsigned char* data, unsigned int len) diff --git a/NXDNReflector/KenwoodNetwork.cpp b/NXDNReflector/KenwoodNetwork.cpp index 2ae3cf9..c4561d9 100644 --- a/NXDNReflector/KenwoodNetwork.cpp +++ b/NXDNReflector/KenwoodNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,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 @@ -89,16 +89,19 @@ bool CKenwoodNetwork::open() return false; } - LogMessage("Opening Kenwood connection"); - - if (!m_rtcpSocket.open(m_rtcpAddr)) + if (!m_rtcpSocket.open(m_rtcpAddr)) { + LogError("Unable to open the Kenwood network connection"); return false; + } if (!m_rtpSocket.open(m_rtpAddr)) { + LogError("Unable to open the Kenwood network connection"); m_rtcpSocket.close(); return false; } + LogMessage("Opened the Kenwood network connection"); + std::uniform_int_distribution dist(0x00000001, 0xfffffffe); m_ssrc = dist(m_random); diff --git a/NXDNReflector/NXDNReflector.cpp b/NXDNReflector/NXDNReflector.cpp index 00f8c50..f397281 100644 --- a/NXDNReflector/NXDNReflector.cpp +++ b/NXDNReflector/NXDNReflector.cpp @@ -181,10 +181,12 @@ void CNXDNReflector::run() return; } + bool icomEnabled = m_conf.getIcomEnabled(); + unsigned short icomTGEnable = 0U; unsigned short icomTGDisable = 0U; - if (m_conf.getIcomEnabled()) { + if (icomEnabled) { ret = openIcomNetwork(); if (!ret) { nxdnNetwork.close(); @@ -196,10 +198,12 @@ void CNXDNReflector::run() icomTGDisable = m_conf.getIcomTGDisable(); } + bool kenwoodEnabled = m_conf.getKenwoodEnabled(); + unsigned short kenwoodTGEnable = 0U; unsigned short kenwoodTGDisable = 0U; - if (m_conf.getKenwoodEnabled()) { + if (kenwoodEnabled) { ret = openKenwoodNetwork(); if (!ret) { nxdnNetwork.close(); @@ -291,7 +295,7 @@ void CNXDNReflector::run() unsigned short dstId = (buffer[7U] << 8) | buffer[8U]; bool grp = (buffer[9U] & 0x01U) == 0x01U; - if (icomTGEnable != 0U && grp && dstId == icomTGEnable) { + if (icomEnabled && icomTGEnable != 0U && grp && dstId == icomTGEnable) { if (m_icomNetwork == NULL) { std::string callsign = lookup->find(srcId); LogMessage("Icom Network link enabled by %s at %s", callsign.c_str(), current->m_callsign.c_str()); @@ -301,7 +305,7 @@ void CNXDNReflector::run() } } - if (kenwoodTGEnable != 0U && grp && dstId == kenwoodTGEnable) { + if (kenwoodEnabled && kenwoodTGEnable != 0U && grp && dstId == kenwoodTGEnable) { if (m_kenwoodNetwork == NULL) { std::string callsign = lookup->find(srcId); LogMessage("Kenwood Network link enabled by %s at %s", callsign.c_str(), current->m_callsign.c_str()); @@ -311,7 +315,7 @@ void CNXDNReflector::run() } } - if (icomTGDisable != 0U && grp && dstId == icomTGDisable) { + if (icomEnabled && icomTGDisable != 0U && grp && dstId == icomTGDisable) { if (m_icomNetwork != NULL) { std::string callsign = lookup->find(srcId); LogMessage("Icom Network link disabled by %s at %s", callsign.c_str(), current->m_callsign.c_str()); @@ -319,7 +323,7 @@ void CNXDNReflector::run() } } - if (kenwoodTGDisable != 0U && grp && dstId == kenwoodTGDisable) { + if (kenwoodEnabled && kenwoodTGDisable != 0U && grp && dstId == kenwoodTGDisable) { if (m_kenwoodNetwork != NULL) { std::string callsign = lookup->find(srcId); LogMessage("Kenwood Network link disabled by %s at %s", callsign.c_str(), current->m_callsign.c_str()); diff --git a/NXDNReflector/Version.h b/NXDNReflector/Version.h index 8d5d4f6..62d2bbe 100644 --- a/NXDNReflector/Version.h +++ b/NXDNReflector/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210213"; +const char* VERSION = "20210309"; #endif