mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2024-11-22 07:24:49 -05:00
Allow simultaneous connection to an Icom NXCore and a Kenwood NXCore.
This commit is contained in:
parent
3d04c4f993
commit
ee52b702d1
@ -31,8 +31,9 @@ enum SECTION {
|
||||
SECTION_GENERAL,
|
||||
SECTION_ID_LOOKUP,
|
||||
SECTION_LOG,
|
||||
SECTION_NETWORK,
|
||||
SECTION_NXCORE
|
||||
SECTION_YSF_NETWORK,
|
||||
SECTION_ICOM_NETWORK,
|
||||
SECTION_KENWOOD_NETWORK
|
||||
};
|
||||
|
||||
CConf::CConf(const std::string& file) :
|
||||
@ -45,14 +46,18 @@ m_logDisplayLevel(0U),
|
||||
m_logFileLevel(0U),
|
||||
m_logFilePath(),
|
||||
m_logFileRoot(),
|
||||
m_networkPort(0U),
|
||||
m_networkDebug(false),
|
||||
m_nxCoreEnabled(false),
|
||||
m_nxCoreProtocol("Icom"),
|
||||
m_nxCoreAddress(),
|
||||
m_nxCoreTGEnable(0U),
|
||||
m_nxCoreTGDisable(0U),
|
||||
m_nxCoreDebug(false)
|
||||
m_ysfPort(0U),
|
||||
m_ysfDebug(false),
|
||||
m_icomEnabled(false),
|
||||
m_icomAddress(),
|
||||
m_icomTGEnable(0U),
|
||||
m_icomTGDisable(0U),
|
||||
m_icomDebug(false),
|
||||
m_kenwoodEnabled(false),
|
||||
m_kenwoodAddress(),
|
||||
m_kenwoodTGEnable(0U),
|
||||
m_kenwoodTGDisable(0U),
|
||||
m_kenwoodDebug(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -82,10 +87,12 @@ bool CConf::read()
|
||||
section = SECTION_ID_LOOKUP;
|
||||
else if (::strncmp(buffer, "[Log]", 5U) == 0)
|
||||
section = SECTION_LOG;
|
||||
else if (::strncmp(buffer, "[Network]", 9U) == 0)
|
||||
section = SECTION_NETWORK;
|
||||
else if (::strncmp(buffer, "[NXCore]", 8U) == 0)
|
||||
section = SECTION_NXCORE;
|
||||
else if (::strncmp(buffer, "[YSF Network]", 13U) == 0)
|
||||
section = SECTION_YSF_NETWORK;
|
||||
else if (::strncmp(buffer, "[Icom Network]", 14U) == 0)
|
||||
section = SECTION_ICOM_NETWORK;
|
||||
else if (::strncmp(buffer, "[Kenwood Network]", 17U) == 0)
|
||||
section = SECTION_KENWOOD_NETWORK;
|
||||
else
|
||||
section = SECTION_NONE;
|
||||
|
||||
@ -116,24 +123,33 @@ bool CConf::read()
|
||||
m_logFileLevel = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "DisplayLevel") == 0)
|
||||
m_logDisplayLevel = (unsigned int)::atoi(value);
|
||||
} else if (section == SECTION_NETWORK) {
|
||||
} else if (section == SECTION_YSF_NETWORK) {
|
||||
if (::strcmp(key, "Port") == 0)
|
||||
m_networkPort = (unsigned int)::atoi(value);
|
||||
m_ysfPort = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_networkDebug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_NXCORE) {
|
||||
m_ysfDebug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_ICOM_NETWORK) {
|
||||
if (::strcmp(key, "Enabled") == 0)
|
||||
m_nxCoreEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Protocol") == 0)
|
||||
m_nxCoreProtocol = value;
|
||||
m_icomEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_nxCoreAddress = value;
|
||||
m_icomAddress = value;
|
||||
else if (::strcmp(key, "TGEnable") == 0)
|
||||
m_nxCoreTGEnable = (unsigned short)::atoi(value);
|
||||
m_icomTGEnable = (unsigned short)::atoi(value);
|
||||
else if (::strcmp(key, "TGDisable") == 0)
|
||||
m_nxCoreTGDisable = (unsigned short)::atoi(value);
|
||||
m_icomTGDisable = (unsigned short)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_nxCoreDebug = ::atoi(value) == 1;
|
||||
m_icomDebug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_KENWOOD_NETWORK) {
|
||||
if (::strcmp(key, "Enabled") == 0)
|
||||
m_kenwoodEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_kenwoodAddress = value;
|
||||
else if (::strcmp(key, "TGEnable") == 0)
|
||||
m_kenwoodTGEnable = (unsigned short)::atoi(value);
|
||||
else if (::strcmp(key, "TGDisable") == 0)
|
||||
m_kenwoodTGDisable = (unsigned short)::atoi(value);
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_kenwoodDebug = ::atoi(value) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,42 +198,62 @@ std::string CConf::getLogFileRoot() const
|
||||
return m_logFileRoot;
|
||||
}
|
||||
|
||||
unsigned int CConf::getNetworkPort() const
|
||||
unsigned int CConf::getYSFPort() const
|
||||
{
|
||||
return m_networkPort;
|
||||
return m_ysfPort;
|
||||
}
|
||||
|
||||
bool CConf::getNetworkDebug() const
|
||||
bool CConf::getYSFDebug() const
|
||||
{
|
||||
return m_networkDebug;
|
||||
return m_ysfDebug;
|
||||
}
|
||||
|
||||
bool CConf::getNXCoreEnabled() const
|
||||
bool CConf::getIcomEnabled() const
|
||||
{
|
||||
return m_nxCoreEnabled;
|
||||
return m_icomEnabled;
|
||||
}
|
||||
|
||||
std::string CConf::getNXCoreProtocol() const
|
||||
std::string CConf::getIcomAddress() const
|
||||
{
|
||||
return m_nxCoreProtocol;
|
||||
return m_icomAddress;
|
||||
}
|
||||
|
||||
std::string CConf::getNXCoreAddress() const
|
||||
unsigned short CConf::getIcomTGEnable() const
|
||||
{
|
||||
return m_nxCoreAddress;
|
||||
return m_icomTGEnable;
|
||||
}
|
||||
|
||||
unsigned short CConf::getNXCoreTGEnable() const
|
||||
unsigned short CConf::getIcomTGDisable() const
|
||||
{
|
||||
return m_nxCoreTGEnable;
|
||||
return m_icomTGDisable;
|
||||
}
|
||||
|
||||
unsigned short CConf::getNXCoreTGDisable() const
|
||||
bool CConf::getIcomDebug() const
|
||||
{
|
||||
return m_nxCoreTGDisable;
|
||||
return m_icomDebug;
|
||||
}
|
||||
|
||||
bool CConf::getNXCoreDebug() const
|
||||
bool CConf::getKenwoodEnabled() const
|
||||
{
|
||||
return m_nxCoreDebug;
|
||||
return m_kenwoodEnabled;
|
||||
}
|
||||
|
||||
std::string CConf::getKenwoodAddress() const
|
||||
{
|
||||
return m_kenwoodAddress;
|
||||
}
|
||||
|
||||
unsigned short CConf::getKenwoodTGEnable() const
|
||||
{
|
||||
return m_kenwoodTGEnable;
|
||||
}
|
||||
|
||||
unsigned short CConf::getKenwoodTGDisable() const
|
||||
{
|
||||
return m_kenwoodTGDisable;
|
||||
}
|
||||
|
||||
bool CConf::getKenwoodDebug() const
|
||||
{
|
||||
return m_kenwoodDebug;
|
||||
}
|
||||
|
@ -44,17 +44,23 @@ public:
|
||||
std::string getLogFilePath() const;
|
||||
std::string getLogFileRoot() const;
|
||||
|
||||
// The Network section
|
||||
unsigned int getNetworkPort() const;
|
||||
bool getNetworkDebug() const;
|
||||
// The YSF Network section
|
||||
unsigned int getYSFPort() const;
|
||||
bool getYSFDebug() const;
|
||||
|
||||
// The NXCore section
|
||||
bool getNXCoreEnabled() const;
|
||||
std::string getNXCoreProtocol() const;
|
||||
std::string getNXCoreAddress() const;
|
||||
unsigned short getNXCoreTGEnable() const;
|
||||
unsigned short getNXCoreTGDisable() const;
|
||||
bool getNXCoreDebug() const;
|
||||
// The Icom Network section
|
||||
bool getIcomEnabled() const;
|
||||
std::string getIcomAddress() const;
|
||||
unsigned short getIcomTGEnable() const;
|
||||
unsigned short getIcomTGDisable() const;
|
||||
bool getIcomDebug() const;
|
||||
|
||||
// The Kenwood Network section
|
||||
bool getKenwoodEnabled() const;
|
||||
std::string getKenwoodAddress() const;
|
||||
unsigned short getKenwoodTGEnable() const;
|
||||
unsigned short getKenwoodTGDisable() const;
|
||||
bool getKenwoodDebug() const;
|
||||
|
||||
private:
|
||||
std::string m_file;
|
||||
@ -69,15 +75,20 @@ private:
|
||||
std::string m_logFilePath;
|
||||
std::string m_logFileRoot;
|
||||
|
||||
unsigned int m_networkPort;
|
||||
bool m_networkDebug;
|
||||
unsigned int m_ysfPort;
|
||||
bool m_ysfDebug;
|
||||
|
||||
bool m_nxCoreEnabled;
|
||||
std::string m_nxCoreProtocol;
|
||||
std::string m_nxCoreAddress;
|
||||
unsigned short m_nxCoreTGEnable;
|
||||
unsigned short m_nxCoreTGDisable;
|
||||
bool m_nxCoreDebug;
|
||||
bool m_icomEnabled;
|
||||
std::string m_icomAddress;
|
||||
unsigned short m_icomTGEnable;
|
||||
unsigned short m_icomTGDisable;
|
||||
bool m_icomDebug;
|
||||
|
||||
bool m_kenwoodEnabled;
|
||||
std::string m_kenwoodAddress;
|
||||
unsigned short m_kenwoodTGEnable;
|
||||
unsigned short m_kenwoodTGDisable;
|
||||
bool m_kenwoodDebug;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014,2016,2018,2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "CoreNetwork.h"
|
||||
|
||||
ICoreNetwork::~ICoreNetwork()
|
||||
{
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014,2016,2018,2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef CoreNetwork_H
|
||||
#define CoreNetwork_H
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <netdb.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class ICoreNetwork {
|
||||
public:
|
||||
virtual ~ICoreNetwork() = 0;
|
||||
|
||||
virtual bool open() = 0;
|
||||
|
||||
virtual bool write(const unsigned char* data, unsigned int length) = 0;
|
||||
|
||||
virtual unsigned int read(unsigned char* data) = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual void clock(unsigned int ms) = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
@ -19,27 +19,26 @@
|
||||
#ifndef IcomNetwork_H
|
||||
#define IcomNetwork_H
|
||||
|
||||
#include "CoreNetwork.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class CIcomNetwork : public ICoreNetwork {
|
||||
class CIcomNetwork {
|
||||
public:
|
||||
CIcomNetwork(const std::string& address, bool debug);
|
||||
virtual ~CIcomNetwork();
|
||||
~CIcomNetwork();
|
||||
|
||||
virtual bool open();
|
||||
bool open();
|
||||
|
||||
virtual bool write(const unsigned char* data, unsigned int len);
|
||||
bool write(const unsigned char* data, unsigned int len);
|
||||
|
||||
virtual unsigned int read(unsigned char* data);
|
||||
unsigned int read(unsigned char* data);
|
||||
|
||||
virtual void close();
|
||||
void close();
|
||||
|
||||
virtual void clock(unsigned int ms);
|
||||
void clock(unsigned int ms);
|
||||
|
||||
private:
|
||||
CUDPSocket m_socket;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef KenwoodNetwork_H
|
||||
#define KenwoodNetwork_H
|
||||
|
||||
#include "CoreNetwork.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "Timer.h"
|
||||
|
||||
@ -27,20 +26,20 @@
|
||||
#include <string>
|
||||
#include <random>
|
||||
|
||||
class CKenwoodNetwork : public ICoreNetwork {
|
||||
class CKenwoodNetwork {
|
||||
public:
|
||||
CKenwoodNetwork(const std::string& address, bool debug);
|
||||
virtual ~CKenwoodNetwork();
|
||||
~CKenwoodNetwork();
|
||||
|
||||
virtual bool open();
|
||||
bool open();
|
||||
|
||||
virtual bool write(const unsigned char* data, unsigned int length);
|
||||
bool write(const unsigned char* data, unsigned int length);
|
||||
|
||||
virtual unsigned int read(unsigned char* data);
|
||||
unsigned int read(unsigned char* data);
|
||||
|
||||
virtual void close();
|
||||
void close();
|
||||
|
||||
virtual void clock(unsigned int ms);
|
||||
void clock(unsigned int ms);
|
||||
|
||||
private:
|
||||
CUDPSocket m_rtpSocket;
|
||||
|
@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
||||
LIBS = -lpthread
|
||||
LDFLAGS = -g
|
||||
|
||||
OBJECTS = Conf.o CoreNetwork.o IcomNetwork.o KenwoodNetwork.o Log.o Mutex.o NXDNCRC.o NXDNLookup.o NXDNNetwork.o NXDNReflector.o StopWatch.o Thread.o Timer.o UDPSocket.o Utils.o
|
||||
OBJECTS = Conf.o IcomNetwork.o KenwoodNetwork.o Log.o Mutex.o NXDNCRC.o NXDNLookup.o NXDNNetwork.o NXDNReflector.o StopWatch.o Thread.o Timer.o UDPSocket.o Utils.o
|
||||
|
||||
all: NXDNReflector
|
||||
|
||||
|
@ -16,10 +16,8 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "KenwoodNetwork.h"
|
||||
#include "NXDNReflector.h"
|
||||
#include "NXDNNetwork.h"
|
||||
#include "IcomNetwork.h"
|
||||
#include "NXDNLookup.h"
|
||||
#include "StopWatch.h"
|
||||
#include "Version.h"
|
||||
@ -81,7 +79,8 @@ int main(int argc, char** argv)
|
||||
|
||||
CNXDNReflector::CNXDNReflector(const std::string& file) :
|
||||
m_conf(file),
|
||||
m_nxCoreNetwork(NULL),
|
||||
m_icomNetwork(NULL),
|
||||
m_kenwoodNetwork(NULL),
|
||||
m_repeaters()
|
||||
{
|
||||
}
|
||||
@ -169,26 +168,41 @@ void CNXDNReflector::run()
|
||||
|
||||
unsigned short tg = m_conf.getTG();
|
||||
|
||||
CNXDNNetwork nxdnNetwork(m_conf.getNetworkPort(), m_conf.getNetworkDebug());
|
||||
CNXDNNetwork nxdnNetwork(m_conf.getYSFPort(), m_conf.getYSFDebug());
|
||||
ret = nxdnNetwork.open();
|
||||
if (!ret) {
|
||||
::LogFinalise();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned short nxCoreTGEnable = 0U;
|
||||
unsigned short nxCoreTGDisable = 0U;
|
||||
unsigned short icomTGEnable = 0U;
|
||||
unsigned short icomTGDisable = 0U;
|
||||
|
||||
if (m_conf.getNXCoreEnabled()) {
|
||||
ret = openNXCore();
|
||||
if (m_conf.getIcomEnabled()) {
|
||||
ret = openIcomNetwork();
|
||||
if (!ret) {
|
||||
nxdnNetwork.close();
|
||||
::LogFinalise();
|
||||
return;
|
||||
}
|
||||
|
||||
nxCoreTGEnable = m_conf.getNXCoreTGEnable();
|
||||
nxCoreTGDisable = m_conf.getNXCoreTGDisable();
|
||||
icomTGEnable = m_conf.getIcomTGEnable();
|
||||
icomTGDisable = m_conf.getIcomTGDisable();
|
||||
}
|
||||
|
||||
unsigned short kenwoodTGEnable = 0U;
|
||||
unsigned short kenwoodTGDisable = 0U;
|
||||
|
||||
if (m_conf.getKenwoodEnabled()) {
|
||||
ret = openKenwoodNetwork();
|
||||
if (!ret) {
|
||||
nxdnNetwork.close();
|
||||
::LogFinalise();
|
||||
return;
|
||||
}
|
||||
|
||||
kenwoodTGEnable = m_conf.getKenwoodTGEnable();
|
||||
kenwoodTGDisable = m_conf.getKenwoodTGDisable();
|
||||
}
|
||||
|
||||
CNXDNLookup* lookup = new CNXDNLookup(m_conf.getLookupName(), m_conf.getLookupTime());
|
||||
@ -203,7 +217,8 @@ void CNXDNReflector::run()
|
||||
LogMessage("Starting NXDNReflector-%s", VERSION);
|
||||
|
||||
CNXDNRepeater* current = NULL;
|
||||
bool nxCoreActive = false;
|
||||
bool icomActive = false;
|
||||
bool kenwoodActive = false;
|
||||
|
||||
unsigned short srcId = 0U;
|
||||
unsigned short dstId = 0U;
|
||||
@ -262,24 +277,46 @@ void CNXDNReflector::run()
|
||||
unsigned short dstId = (buffer[7U] << 8) | buffer[8U];
|
||||
bool grp = (buffer[9U] & 0x01U) == 0x01U;
|
||||
|
||||
if (nxCoreTGEnable != 0U && grp && dstId == nxCoreTGEnable) {
|
||||
if (m_nxCoreNetwork == NULL) {
|
||||
if (icomTGEnable != 0U && grp && dstId == icomTGEnable) {
|
||||
if (m_icomNetwork == NULL) {
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("NXCore link enabled by %s at %s", callsign.c_str(), current->m_callsign.c_str());
|
||||
bool ok = openNXCore();
|
||||
LogMessage("Icom Network link enabled by %s at %s", callsign.c_str(), current->m_callsign.c_str());
|
||||
bool ok = openIcomNetwork();
|
||||
if (!ok)
|
||||
LogWarning("Unable to open the NXCore link");
|
||||
LogWarning("Unable to open the Icom Network link");
|
||||
}
|
||||
} else if (nxCoreTGDisable != 0U && grp && dstId == nxCoreTGDisable) {
|
||||
if (m_nxCoreNetwork != NULL) {
|
||||
}
|
||||
|
||||
if (kenwoodTGEnable != 0U && grp && dstId == kenwoodTGEnable) {
|
||||
if (m_kenwoodNetwork == NULL) {
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("NXCore link disabled by %s at %s", callsign.c_str(), current->m_callsign.c_str());
|
||||
closeNXCore();
|
||||
LogMessage("Kenwood Network link enabled by %s at %s", callsign.c_str(), current->m_callsign.c_str());
|
||||
bool ok = openKenwoodNetwork();
|
||||
if (!ok)
|
||||
LogWarning("Unable to open the Kenwood Network link");
|
||||
}
|
||||
} else if (grp && dstId == tg) {
|
||||
}
|
||||
|
||||
if (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());
|
||||
closeIcomNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
if (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());
|
||||
closeKenwoodNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
if (grp && dstId == tg) {
|
||||
rpt->m_timer.start();
|
||||
|
||||
if (current == NULL && !nxCoreActive) {
|
||||
if (current == NULL && !(icomActive || kenwoodActive)) {
|
||||
current = rpt;
|
||||
|
||||
std::string callsign = lookup->find(srcId);
|
||||
@ -296,8 +333,11 @@ void CNXDNReflector::run()
|
||||
nxdnNetwork.write(buffer, len, addr, prt);
|
||||
}
|
||||
|
||||
if (m_nxCoreNetwork != NULL)
|
||||
m_nxCoreNetwork->write(buffer, len);
|
||||
if (m_icomNetwork != NULL)
|
||||
m_icomNetwork->write(buffer, len);
|
||||
|
||||
if (m_kenwoodNetwork != NULL)
|
||||
m_kenwoodNetwork->write(buffer, len);
|
||||
|
||||
if ((buffer[9U] & 0x08U) == 0x08U) {
|
||||
LogMessage("Received end of transmission");
|
||||
@ -313,11 +353,11 @@ void CNXDNReflector::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_nxCoreNetwork != NULL) {
|
||||
len = m_nxCoreNetwork->read(buffer);
|
||||
if (m_icomNetwork != NULL) {
|
||||
len = m_icomNetwork->read(buffer);
|
||||
if (len > 0U) {
|
||||
if (current == NULL) {
|
||||
if (!nxCoreActive) {
|
||||
if (!icomActive) {
|
||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x01U) {
|
||||
bool tempGrp = (buffer[7U] & 0x20U) == 0x20U;
|
||||
unsigned short tempSrcId = (buffer[8U] << 8) | buffer[9U];
|
||||
@ -330,9 +370,9 @@ void CNXDNReflector::run()
|
||||
dstId = tempDstId;
|
||||
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
LogMessage("Transmission from %s on Icom Network to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
|
||||
nxCoreActive = true;
|
||||
icomActive = true;
|
||||
}
|
||||
}
|
||||
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x09U) {
|
||||
@ -347,14 +387,14 @@ void CNXDNReflector::run()
|
||||
dstId = tempDstId;
|
||||
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
LogMessage("Transmission from %s on Icom Network to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
|
||||
nxCoreActive = true;
|
||||
icomActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nxCoreActive) {
|
||||
if (icomActive) {
|
||||
watchdogTimer.start();
|
||||
|
||||
for (std::vector<CNXDNRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||
@ -363,14 +403,85 @@ void CNXDNReflector::run()
|
||||
nxdnNetwork.write(buffer, len, srcId, dstId, grp, addr, prt);
|
||||
}
|
||||
|
||||
if (m_kenwoodNetwork != NULL)
|
||||
m_kenwoodNetwork->write(buffer, len);
|
||||
|
||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x08U) {
|
||||
LogMessage("Received end of transmission");
|
||||
nxCoreActive = false;
|
||||
icomActive = false;
|
||||
watchdogTimer.stop();
|
||||
}
|
||||
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x08U) {
|
||||
LogMessage("Received end of transmission");
|
||||
nxCoreActive = false;
|
||||
icomActive = false;
|
||||
watchdogTimer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_kenwoodNetwork != NULL) {
|
||||
len = m_kenwoodNetwork->read(buffer);
|
||||
if (len > 0U) {
|
||||
if (current == NULL) {
|
||||
if (!kenwoodActive) {
|
||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x01U) {
|
||||
bool tempGrp = (buffer[7U] & 0x20U) == 0x20U;
|
||||
unsigned short tempSrcId = (buffer[8U] << 8) | buffer[9U];
|
||||
unsigned short tempDstId = (buffer[10U] << 8) | buffer[11U];
|
||||
|
||||
if (tempGrp && tempDstId == tg) {
|
||||
// Save the grp, src and dest for use in the NXDN Protocol messages
|
||||
grp = tempGrp;
|
||||
srcId = tempSrcId;
|
||||
dstId = tempDstId;
|
||||
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("Transmission from %s on Kenwood Network to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
|
||||
kenwoodActive = true;
|
||||
}
|
||||
}
|
||||
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x09U) {
|
||||
bool tempGrp = (buffer[4U] & 0x20U) == 0x20U;
|
||||
unsigned short tempSrcId = (buffer[5U] << 8) | buffer[6U];
|
||||
unsigned short tempDstId = (buffer[7U] << 8) | buffer[8U];
|
||||
|
||||
if (tempGrp && tempDstId == tg) {
|
||||
// Save the grp, src and dest for use in the NXDN Protocol messages
|
||||
grp = tempGrp;
|
||||
srcId = tempSrcId;
|
||||
dstId = tempDstId;
|
||||
|
||||
std::string callsign = lookup->find(srcId);
|
||||
LogMessage("Transmission from %s on Kenwood Network to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||
|
||||
kenwoodActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kenwoodActive) {
|
||||
watchdogTimer.start();
|
||||
|
||||
for (std::vector<CNXDNRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||
in_addr addr = (*it)->m_address;
|
||||
unsigned int prt = (*it)->m_port;
|
||||
nxdnNetwork.write(buffer, len, srcId, dstId, grp, addr, prt);
|
||||
}
|
||||
|
||||
if (m_icomNetwork != NULL)
|
||||
m_icomNetwork->write(buffer, len);
|
||||
|
||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x08U) {
|
||||
LogMessage("Received end of transmission");
|
||||
kenwoodActive = false;
|
||||
watchdogTimer.stop();
|
||||
}
|
||||
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x08U) {
|
||||
LogMessage("Received end of transmission");
|
||||
kenwoodActive = false;
|
||||
watchdogTimer.stop();
|
||||
}
|
||||
}
|
||||
@ -403,7 +514,8 @@ void CNXDNReflector::run()
|
||||
LogMessage("Network watchdog has expired");
|
||||
watchdogTimer.stop();
|
||||
current = NULL;
|
||||
nxCoreActive = false;
|
||||
icomActive = false;
|
||||
kenwoodActive = false;
|
||||
}
|
||||
|
||||
dumpTimer.clock(ms);
|
||||
@ -412,8 +524,11 @@ void CNXDNReflector::run()
|
||||
dumpTimer.start();
|
||||
}
|
||||
|
||||
if (m_nxCoreNetwork != NULL)
|
||||
m_nxCoreNetwork->clock(ms);
|
||||
if (m_icomNetwork != NULL)
|
||||
m_icomNetwork->clock(ms);
|
||||
|
||||
if (m_kenwoodNetwork != NULL)
|
||||
m_kenwoodNetwork->clock(ms);
|
||||
|
||||
if (ms < 5U)
|
||||
CThread::sleep(5U);
|
||||
@ -421,7 +536,9 @@ void CNXDNReflector::run()
|
||||
|
||||
nxdnNetwork.close();
|
||||
|
||||
closeNXCore();
|
||||
closeIcomNetwork();
|
||||
|
||||
closeKenwoodNetwork();
|
||||
|
||||
lookup->stop();
|
||||
|
||||
@ -457,28 +574,46 @@ void CNXDNReflector::dumpRepeaters() const
|
||||
}
|
||||
}
|
||||
|
||||
bool CNXDNReflector::openNXCore()
|
||||
bool CNXDNReflector::openIcomNetwork()
|
||||
{
|
||||
std::string protocol = m_conf.getNXCoreProtocol();
|
||||
if (protocol == "Kenwood")
|
||||
m_nxCoreNetwork = new CKenwoodNetwork(m_conf.getNXCoreAddress(), m_conf.getNXCoreDebug());
|
||||
else
|
||||
m_nxCoreNetwork = new CIcomNetwork(m_conf.getNXCoreAddress(), m_conf.getNXCoreDebug());
|
||||
bool ret = m_nxCoreNetwork->open();
|
||||
m_icomNetwork = new CIcomNetwork(m_conf.getIcomAddress(), m_conf.getIcomDebug());
|
||||
bool ret = m_icomNetwork->open();
|
||||
if (!ret) {
|
||||
delete m_nxCoreNetwork;
|
||||
m_nxCoreNetwork = NULL;
|
||||
delete m_icomNetwork;
|
||||
m_icomNetwork = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNXDNReflector::closeNXCore()
|
||||
bool CNXDNReflector::openKenwoodNetwork()
|
||||
{
|
||||
if (m_nxCoreNetwork != NULL) {
|
||||
m_nxCoreNetwork->close();
|
||||
delete m_nxCoreNetwork;
|
||||
m_nxCoreNetwork = NULL;
|
||||
m_kenwoodNetwork = new CKenwoodNetwork(m_conf.getKenwoodAddress(), m_conf.getKenwoodDebug());
|
||||
bool ret = m_kenwoodNetwork->open();
|
||||
if (!ret) {
|
||||
delete m_kenwoodNetwork;
|
||||
m_kenwoodNetwork = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNXDNReflector::closeIcomNetwork()
|
||||
{
|
||||
if (m_icomNetwork != NULL) {
|
||||
m_icomNetwork->close();
|
||||
delete m_icomNetwork;
|
||||
m_icomNetwork = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CNXDNReflector::closeKenwoodNetwork()
|
||||
{
|
||||
if (m_kenwoodNetwork != NULL) {
|
||||
m_kenwoodNetwork->close();
|
||||
delete m_kenwoodNetwork;
|
||||
m_kenwoodNetwork = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,8 @@
|
||||
#if !defined(NXDNReflector_H)
|
||||
#define NXDNReflector_H
|
||||
|
||||
#include "CoreNetwork.h"
|
||||
#include "KenwoodNetwork.h"
|
||||
#include "IcomNetwork.h"
|
||||
#include "Timer.h"
|
||||
#include "Conf.h"
|
||||
|
||||
@ -65,14 +66,17 @@ public:
|
||||
|
||||
private:
|
||||
CConf m_conf;
|
||||
ICoreNetwork* m_nxCoreNetwork;
|
||||
CIcomNetwork* m_icomNetwork;
|
||||
CKenwoodNetwork* m_kenwoodNetwork;
|
||||
std::vector<CNXDNRepeater*> m_repeaters;
|
||||
|
||||
CNXDNRepeater* findRepeater(const in_addr& address, unsigned int port) const;
|
||||
void dumpRepeaters() const;
|
||||
|
||||
bool openNXCore();
|
||||
void closeNXCore();
|
||||
bool openIcomNetwork();
|
||||
bool openKenwoodNetwork();
|
||||
void closeIcomNetwork();
|
||||
void closeKenwoodNetwork();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -13,13 +13,20 @@ FileLevel=1
|
||||
FilePath=.
|
||||
FileRoot=NXDNReflector
|
||||
|
||||
[Network]
|
||||
[YSF Network]
|
||||
Port=41400
|
||||
Debug=0
|
||||
|
||||
[NXCore]
|
||||
[Icom Network]
|
||||
Enabled=0
|
||||
# Address=208.111.3.45
|
||||
Address=44.131.4.1
|
||||
# TGEnable=1234
|
||||
# TGDisable=3456
|
||||
Debug=0
|
||||
|
||||
[Kenwood Network]
|
||||
Enabled=0
|
||||
Protocol=Icom
|
||||
# Address=208.111.3.45
|
||||
Address=44.131.4.1
|
||||
# TGEnable=1234
|
||||
|
@ -20,7 +20,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Conf.h" />
|
||||
<ClInclude Include="CoreNetwork.h" />
|
||||
<ClInclude Include="IcomNetwork.h" />
|
||||
<ClInclude Include="KenwoodNetwork.h" />
|
||||
<ClInclude Include="NXDNCRC.h" />
|
||||
@ -38,7 +37,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Conf.cpp" />
|
||||
<ClCompile Include="CoreNetwork.cpp" />
|
||||
<ClCompile Include="IcomNetwork.cpp" />
|
||||
<ClCompile Include="KenwoodNetwork.cpp" />
|
||||
<ClCompile Include="NXDNCRC.cpp" />
|
||||
|
@ -53,9 +53,6 @@
|
||||
<ClInclude Include="KenwoodNetwork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CoreNetwork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NXDNCRC.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -100,9 +97,6 @@
|
||||
<ClCompile Include="KenwoodNetwork.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CoreNetwork.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NXDNCRC.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -19,6 +19,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20200701";
|
||||
const char* VERSION = "20200822";
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user