First version with the old and new protocols.

This commit is contained in:
Jonathan Naylor
2021-01-30 22:49:00 +00:00
parent c2044ea6a3
commit 45d161ce07
7 changed files with 45 additions and 26 deletions

View File

@@ -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
@@ -46,12 +46,14 @@ enum SECTION {
CConf::CConf(const std::string& file) :
m_file(file),
m_daemon(false),
m_rfTimeout(10U),
m_netTimeout(10U),
m_rptAddress("127.0.0.1"),
m_rptPort(62032U),
m_localAddress("127.0.0.1"),
m_localPort(62031U),
m_rfTimeout(10U),
m_netTimeout(10U),
m_rptProtocol("New"),
m_split(false),
m_ruleTrace(false),
m_debug(false),
m_voiceEnabled(true),
@@ -280,6 +282,10 @@ bool CConf::read()
m_localAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_localPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "RptProtocol") == 0)
m_rptProtocol = value;
else if (::strcmp(key, "Split") == 0)
m_split = ::atoi(value) == 1;
else if (::strcmp(key, "RuleTrace") == 0)
m_ruleTrace = ::atoi(value) == 1;
else if (::strcmp(key, "Debug") == 0)
@@ -990,6 +996,16 @@ bool CConf::getDaemon() const
return m_daemon;
}
unsigned int CConf::getRFTimeout() const
{
return m_rfTimeout;
}
unsigned int CConf::getNetTimeout() const
{
return m_netTimeout;
}
std::string CConf::getRptAddress() const
{
return m_rptAddress;
@@ -1010,14 +1026,14 @@ unsigned int CConf::getLocalPort() const
return m_localPort;
}
unsigned int CConf::getRFTimeout() const
std::string CConf::getRptProtocol() const
{
return m_rfTimeout;
return m_rptProtocol;
}
unsigned int CConf::getNetTimeout() const
bool CConf::getSplit() const
{
return m_netTimeout;
return m_split;
}
bool CConf::getRuleTrace() const

10
Conf.h
View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2019,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
@@ -85,6 +85,8 @@ public:
unsigned int getRptPort() const;
std::string getLocalAddress() const;
unsigned int getLocalPort() const;
std::string getRptProtocol() const;
bool getSplit() const;
bool getRuleTrace() const;
bool getDebug() const;
@@ -244,12 +246,14 @@ public:
private:
std::string m_file;
bool m_daemon;
unsigned int m_rfTimeout;
unsigned int m_netTimeout;
std::string m_rptAddress;
unsigned int m_rptPort;
std::string m_localAddress;
unsigned int m_localPort;
unsigned int m_rfTimeout;
unsigned int m_netTimeout;
std::string m_rptProtocol;
bool m_split;
bool m_ruleTrace;
bool m_debug;

View File

@@ -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
@@ -17,6 +17,7 @@
*/
#include "MMDVMNetworkNew.h"
#include "MMDVMNetworkOld.h"
#include "RewriteType.h"
#include "DMRSlotType.h"
#include "RewriteSrc.h"
@@ -1308,6 +1309,8 @@ bool CDMRGateway::createMMDVM()
unsigned int rptPort = m_conf.getRptPort();
std::string localAddress = m_conf.getLocalAddress();
unsigned int localPort = m_conf.getLocalPort();
std::string protocol = m_conf.getRptProtocol();
bool split = m_conf.getSplit();
bool debug = m_conf.getDebug();
LogInfo("MMDVM Network Parameters");
@@ -1315,8 +1318,13 @@ bool CDMRGateway::createMMDVM()
LogInfo(" Rpt Port: %u", rptPort);
LogInfo(" Local Address: %s", localAddress.c_str());
LogInfo(" Local Port: %u", localPort);
LogInfo(" Protocol: %s", protocol.c_str());
LogInfo(" Split: %s", split ? "yes" : "no");
m_repeater = new CMMDVMNetworkNew(rptAddress, rptPort, localAddress, localPort, debug);
if (protocol == "old")
m_repeater = new CMMDVMNetworkOld(rptAddress, rptPort, localAddress, localPort, debug);
else
m_repeater = new CMMDVMNetworkNew(rptAddress, rptPort, localAddress, localPort, debug);
bool ret = m_repeater->open();
if (!ret) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2019,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

View File

@@ -6,6 +6,7 @@ RptAddress=127.0.0.1
RptPort=62032
LocalAddress=127.0.0.1
LocalPort=62031
Split=0
RuleTrace=0
Daemon=0
Debug=0

View File

@@ -40,7 +40,6 @@ m_debug(debug),
m_socket(localAddress, localPort),
m_buffer(NULL),
m_rxData(1000U, "MMDVM Network"),
m_options(),
m_configData(NULL),
m_configLen(0U),
m_radioPositionData(NULL),
@@ -77,12 +76,7 @@ CMMDVMNetworkOld::~CMMDVMNetworkOld()
delete[] m_homePositionData;
}
std::string CMMDVMNetworkOld::getOptions() const
{
return m_options;
}
unsigned int CMMDVMNetworkOld::getConfig(unsigned char* config) const
unsigned int CMMDVMNetworkOld::getShortConfig(unsigned char* config) const
{
if (m_configData == 0U)
return 0U;
@@ -346,6 +340,7 @@ void CMMDVMNetworkOld::clock(unsigned int ms)
} else if (::memcmp(m_buffer, "RPTCL", 5U) == 0) {
::LogMessage("MMDVM Network, The connected MMDVM is closing down");
} else if (::memcmp(m_buffer, "RPTC", 4U) == 0) {
// XXX FIXME !!!
m_configLen = length - 8U;
m_configData = new unsigned char[m_configLen];
::memcpy(m_configData, m_buffer + 8U, m_configLen);
@@ -355,8 +350,6 @@ void CMMDVMNetworkOld::clock(unsigned int ms)
::memcpy(ack + 6U, m_netId, 4U);
m_socket.write(ack, 10U, m_rptAddr, m_rptAddrLen);
} else if (::memcmp(m_buffer, "RPTO", 4U) == 0) {
m_options = std::string((char*)(m_buffer + 8U), length - 8U);
unsigned char ack[10U];
::memcpy(ack + 0U, "RPTACK", 6U);
::memcpy(ack + 6U, m_netId, 4U);

View File

@@ -33,9 +33,7 @@ public:
CMMDVMNetworkOld(const std::string& rptAddress, unsigned int rptPort, const std::string& localAddress, unsigned int localPort, bool debug);
virtual ~CMMDVMNetworkOld();
virtual std::string getOptions() const;
virtual unsigned int getConfig(unsigned char* config) const;
virtual unsigned int getShortConfig(unsigned char* config) const;
virtual unsigned int getId() const;
@@ -66,7 +64,6 @@ private:
CUDPSocket m_socket;
unsigned char* m_buffer;
CRingBuffer<unsigned char> m_rxData;
std::string m_options;
unsigned char* m_configData;
unsigned int m_configLen;
unsigned char* m_radioPositionData;