mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2025-04-12 06:18:27 -04:00
Beginnings of Kenwood repeater support.
This commit is contained in:
parent
031d47816c
commit
f51115c1d0
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014,2016,2018 by Jonathan Naylor G4KLX
|
||||
* 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
|
||||
@ -121,3 +121,7 @@ void CIcomNetwork::close()
|
||||
|
||||
LogMessage("Closing Icom connection");
|
||||
}
|
||||
|
||||
void CIcomNetwork::clock(unsigned int ms)
|
||||
{
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014,2016,2018 by Jonathan Naylor G4KLX
|
||||
* 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
|
||||
@ -19,24 +19,27 @@
|
||||
#ifndef IcomNetwork_H
|
||||
#define IcomNetwork_H
|
||||
|
||||
#include "RptNetwork.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class CIcomNetwork {
|
||||
class CIcomNetwork : public IRptNetwork {
|
||||
public:
|
||||
CIcomNetwork(unsigned int localPort, bool debug);
|
||||
~CIcomNetwork();
|
||||
virtual ~CIcomNetwork();
|
||||
|
||||
bool open();
|
||||
virtual bool open();
|
||||
|
||||
bool write(const unsigned char* data, unsigned int length, const in_addr& address, unsigned int port);
|
||||
virtual bool write(const unsigned char* data, unsigned int length, const in_addr& address, unsigned int port);
|
||||
|
||||
bool read(unsigned char* data, in_addr& address, unsigned int& port);
|
||||
virtual bool read(unsigned char* data, in_addr& address, unsigned int& port);
|
||||
|
||||
void close();
|
||||
virtual void close();
|
||||
|
||||
virtual void clock(unsigned int ms);
|
||||
|
||||
private:
|
||||
CUDPSocket m_socket;
|
||||
|
@ -5,7 +5,7 @@ LIBS = -lpthread
|
||||
LDFLAGS = -g
|
||||
|
||||
OBJECTS = APRSWriter.o APRSWriterThread.o Conf.o GPSHandler.o IcomNetwork.o Log.o Mutex.o NXDNCRC.o NXDNGateway.o NXDNLookup.o NXDNNetwork.o Reflectors.o \
|
||||
StopWatch.o TCPSocket.o Thread.o Timer.o UDPSocket.o Utils.o Voice.o
|
||||
RptNetwork.o StopWatch.o TCPSocket.o Thread.o Timer.o UDPSocket.o Utils.o Voice.o
|
||||
|
||||
all: NXDNGateway
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016,2017,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
|
||||
@ -19,6 +19,7 @@
|
||||
#include "IcomNetwork.h"
|
||||
#include "NXDNNetwork.h"
|
||||
#include "NXDNGateway.h"
|
||||
#include "RptNetwork.h"
|
||||
#include "NXDNLookup.h"
|
||||
#include "Reflectors.h"
|
||||
#include "GPSHandler.h"
|
||||
@ -179,8 +180,8 @@ void CNXDNGateway::run()
|
||||
|
||||
createGPS();
|
||||
|
||||
CIcomNetwork localNetwork(m_conf.getMyPort(), m_conf.getRptDebug());
|
||||
ret = localNetwork.open();
|
||||
IRptNetwork* localNetwork = new CIcomNetwork(m_conf.getMyPort(), m_conf.getRptDebug());
|
||||
ret = localNetwork->open();
|
||||
if (!ret) {
|
||||
::LogFinalise();
|
||||
return;
|
||||
@ -189,7 +190,8 @@ void CNXDNGateway::run()
|
||||
CNXDNNetwork remoteNetwork(m_conf.getNetworkPort(), m_conf.getCallsign(), m_conf.getNetworkDebug());
|
||||
ret = remoteNetwork.open();
|
||||
if (!ret) {
|
||||
localNetwork.close();
|
||||
localNetwork->close();
|
||||
delete localNetwork;
|
||||
::LogFinalise();
|
||||
return;
|
||||
}
|
||||
@ -272,7 +274,7 @@ startupId = 9999U;
|
||||
bool grp = (buffer[9U] & 0x01U) == 0x01U;
|
||||
|
||||
if (grp && currentId == dstId)
|
||||
localNetwork.write(buffer + 10U, len - 10U, rptAddr, rptPort);
|
||||
localNetwork->write(buffer + 10U, len - 10U, rptAddr, rptPort);
|
||||
}
|
||||
|
||||
// Any network activity is proof that the reflector is alive
|
||||
@ -281,7 +283,7 @@ startupId = 9999U;
|
||||
}
|
||||
|
||||
// From the MMDVM to the reflector or control data
|
||||
len = localNetwork.read(buffer, address, port);
|
||||
len = localNetwork->read(buffer, address, port);
|
||||
if (len > 0U) {
|
||||
// Only process the beginning and ending voice blocks here
|
||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && (buffer[5U] == 0x01U || buffer[5U] == 0x08U)) {
|
||||
@ -381,7 +383,7 @@ startupId = 9999U;
|
||||
if (voice != NULL) {
|
||||
unsigned int length = voice->read(buffer);
|
||||
if (length > 0U)
|
||||
localNetwork.write(buffer, length, rptAddr, rptPort);
|
||||
localNetwork->write(buffer, length, rptAddr, rptPort);
|
||||
}
|
||||
|
||||
unsigned int ms = stopWatch.elapsed();
|
||||
@ -389,6 +391,8 @@ startupId = 9999U;
|
||||
|
||||
reflectors.clock(ms);
|
||||
|
||||
localNetwork->clock(ms);
|
||||
|
||||
if (voice != NULL)
|
||||
voice->clock(ms);
|
||||
|
||||
@ -469,7 +473,8 @@ startupId = 9999U;
|
||||
|
||||
delete voice;
|
||||
|
||||
localNetwork.close();
|
||||
localNetwork->close();
|
||||
delete localNetwork;
|
||||
|
||||
remoteNetwork.close();
|
||||
|
||||
|
@ -159,6 +159,7 @@
|
||||
<ClInclude Include="NXDNNetwork.h" />
|
||||
<ClInclude Include="Reflectors.h" />
|
||||
<ClInclude Include="RingBuffer.h" />
|
||||
<ClInclude Include="RptNetwork.h" />
|
||||
<ClInclude Include="StopWatch.h" />
|
||||
<ClInclude Include="TCPSocket.h" />
|
||||
<ClInclude Include="Thread.h" />
|
||||
@ -181,6 +182,7 @@
|
||||
<ClCompile Include="NXDNLookup.cpp" />
|
||||
<ClCompile Include="NXDNNetwork.cpp" />
|
||||
<ClCompile Include="Reflectors.cpp" />
|
||||
<ClCompile Include="RptNetwork.cpp" />
|
||||
<ClCompile Include="StopWatch.cpp" />
|
||||
<ClCompile Include="TCPSocket.cpp" />
|
||||
<ClCompile Include="Thread.cpp" />
|
||||
|
@ -74,6 +74,9 @@
|
||||
<ClInclude Include="GPSHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RptNetwork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Conf.cpp">
|
||||
@ -133,5 +136,8 @@
|
||||
<ClCompile Include="GPSHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RptNetwork.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
23
NXDNGateway/RptNetwork.cpp
Normal file
23
NXDNGateway/RptNetwork.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 "RptNetwork.h"
|
||||
|
||||
IRptNetwork::~IRptNetwork()
|
||||
{
|
||||
}
|
55
NXDNGateway/RptNetwork.h
Normal file
55
NXDNGateway/RptNetwork.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 RptNetwork_H
|
||||
#define RptNetwork_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 IRptNetwork {
|
||||
public:
|
||||
virtual ~IRptNetwork() = 0;
|
||||
|
||||
virtual bool open() = 0;
|
||||
|
||||
virtual bool write(const unsigned char* data, unsigned int length, const in_addr& address, unsigned int port) = 0;
|
||||
|
||||
virtual bool read(unsigned char* data, in_addr& address, unsigned int& port) = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual void clock(unsigned int ms) = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user