mirror of https://github.com/g4klx/DMRGateway
First version with the old and new protocols.
This commit is contained in:
parent
c2044ea6a3
commit
45d161ce07
30
Conf.cpp
30
Conf.cpp
|
|
@ -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
|
* 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
|
||||||
|
|
@ -46,12 +46,14 @@ enum SECTION {
|
||||||
CConf::CConf(const std::string& file) :
|
CConf::CConf(const std::string& file) :
|
||||||
m_file(file),
|
m_file(file),
|
||||||
m_daemon(false),
|
m_daemon(false),
|
||||||
|
m_rfTimeout(10U),
|
||||||
|
m_netTimeout(10U),
|
||||||
m_rptAddress("127.0.0.1"),
|
m_rptAddress("127.0.0.1"),
|
||||||
m_rptPort(62032U),
|
m_rptPort(62032U),
|
||||||
m_localAddress("127.0.0.1"),
|
m_localAddress("127.0.0.1"),
|
||||||
m_localPort(62031U),
|
m_localPort(62031U),
|
||||||
m_rfTimeout(10U),
|
m_rptProtocol("New"),
|
||||||
m_netTimeout(10U),
|
m_split(false),
|
||||||
m_ruleTrace(false),
|
m_ruleTrace(false),
|
||||||
m_debug(false),
|
m_debug(false),
|
||||||
m_voiceEnabled(true),
|
m_voiceEnabled(true),
|
||||||
|
|
@ -280,6 +282,10 @@ bool CConf::read()
|
||||||
m_localAddress = value;
|
m_localAddress = value;
|
||||||
else if (::strcmp(key, "LocalPort") == 0)
|
else if (::strcmp(key, "LocalPort") == 0)
|
||||||
m_localPort = (unsigned int)::atoi(value);
|
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)
|
else if (::strcmp(key, "RuleTrace") == 0)
|
||||||
m_ruleTrace = ::atoi(value) == 1;
|
m_ruleTrace = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "Debug") == 0)
|
else if (::strcmp(key, "Debug") == 0)
|
||||||
|
|
@ -990,6 +996,16 @@ bool CConf::getDaemon() const
|
||||||
return m_daemon;
|
return m_daemon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getRFTimeout() const
|
||||||
|
{
|
||||||
|
return m_rfTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getNetTimeout() const
|
||||||
|
{
|
||||||
|
return m_netTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CConf::getRptAddress() const
|
std::string CConf::getRptAddress() const
|
||||||
{
|
{
|
||||||
return m_rptAddress;
|
return m_rptAddress;
|
||||||
|
|
@ -1010,14 +1026,14 @@ unsigned int CConf::getLocalPort() const
|
||||||
return m_localPort;
|
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
|
bool CConf::getRuleTrace() const
|
||||||
|
|
|
||||||
10
Conf.h
10
Conf.h
|
|
@ -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
|
* 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
|
||||||
|
|
@ -85,6 +85,8 @@ public:
|
||||||
unsigned int getRptPort() const;
|
unsigned int getRptPort() const;
|
||||||
std::string getLocalAddress() const;
|
std::string getLocalAddress() const;
|
||||||
unsigned int getLocalPort() const;
|
unsigned int getLocalPort() const;
|
||||||
|
std::string getRptProtocol() const;
|
||||||
|
bool getSplit() const;
|
||||||
bool getRuleTrace() const;
|
bool getRuleTrace() const;
|
||||||
bool getDebug() const;
|
bool getDebug() const;
|
||||||
|
|
||||||
|
|
@ -244,12 +246,14 @@ public:
|
||||||
private:
|
private:
|
||||||
std::string m_file;
|
std::string m_file;
|
||||||
bool m_daemon;
|
bool m_daemon;
|
||||||
|
unsigned int m_rfTimeout;
|
||||||
|
unsigned int m_netTimeout;
|
||||||
std::string m_rptAddress;
|
std::string m_rptAddress;
|
||||||
unsigned int m_rptPort;
|
unsigned int m_rptPort;
|
||||||
std::string m_localAddress;
|
std::string m_localAddress;
|
||||||
unsigned int m_localPort;
|
unsigned int m_localPort;
|
||||||
unsigned int m_rfTimeout;
|
std::string m_rptProtocol;
|
||||||
unsigned int m_netTimeout;
|
bool m_split;
|
||||||
bool m_ruleTrace;
|
bool m_ruleTrace;
|
||||||
bool m_debug;
|
bool m_debug;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MMDVMNetworkNew.h"
|
#include "MMDVMNetworkNew.h"
|
||||||
|
#include "MMDVMNetworkOld.h"
|
||||||
#include "RewriteType.h"
|
#include "RewriteType.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
#include "RewriteSrc.h"
|
#include "RewriteSrc.h"
|
||||||
|
|
@ -1308,6 +1309,8 @@ bool CDMRGateway::createMMDVM()
|
||||||
unsigned int rptPort = m_conf.getRptPort();
|
unsigned int rptPort = m_conf.getRptPort();
|
||||||
std::string localAddress = m_conf.getLocalAddress();
|
std::string localAddress = m_conf.getLocalAddress();
|
||||||
unsigned int localPort = m_conf.getLocalPort();
|
unsigned int localPort = m_conf.getLocalPort();
|
||||||
|
std::string protocol = m_conf.getRptProtocol();
|
||||||
|
bool split = m_conf.getSplit();
|
||||||
bool debug = m_conf.getDebug();
|
bool debug = m_conf.getDebug();
|
||||||
|
|
||||||
LogInfo("MMDVM Network Parameters");
|
LogInfo("MMDVM Network Parameters");
|
||||||
|
|
@ -1315,8 +1318,13 @@ bool CDMRGateway::createMMDVM()
|
||||||
LogInfo(" Rpt Port: %u", rptPort);
|
LogInfo(" Rpt Port: %u", rptPort);
|
||||||
LogInfo(" Local Address: %s", localAddress.c_str());
|
LogInfo(" Local Address: %s", localAddress.c_str());
|
||||||
LogInfo(" Local Port: %u", localPort);
|
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();
|
bool ret = m_repeater->open();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ RptAddress=127.0.0.1
|
||||||
RptPort=62032
|
RptPort=62032
|
||||||
LocalAddress=127.0.0.1
|
LocalAddress=127.0.0.1
|
||||||
LocalPort=62031
|
LocalPort=62031
|
||||||
|
Split=0
|
||||||
RuleTrace=0
|
RuleTrace=0
|
||||||
Daemon=0
|
Daemon=0
|
||||||
Debug=0
|
Debug=0
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ m_debug(debug),
|
||||||
m_socket(localAddress, localPort),
|
m_socket(localAddress, localPort),
|
||||||
m_buffer(NULL),
|
m_buffer(NULL),
|
||||||
m_rxData(1000U, "MMDVM Network"),
|
m_rxData(1000U, "MMDVM Network"),
|
||||||
m_options(),
|
|
||||||
m_configData(NULL),
|
m_configData(NULL),
|
||||||
m_configLen(0U),
|
m_configLen(0U),
|
||||||
m_radioPositionData(NULL),
|
m_radioPositionData(NULL),
|
||||||
|
|
@ -77,12 +76,7 @@ CMMDVMNetworkOld::~CMMDVMNetworkOld()
|
||||||
delete[] m_homePositionData;
|
delete[] m_homePositionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMMDVMNetworkOld::getOptions() const
|
unsigned int CMMDVMNetworkOld::getShortConfig(unsigned char* config) const
|
||||||
{
|
|
||||||
return m_options;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CMMDVMNetworkOld::getConfig(unsigned char* config) const
|
|
||||||
{
|
{
|
||||||
if (m_configData == 0U)
|
if (m_configData == 0U)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
@ -346,6 +340,7 @@ void CMMDVMNetworkOld::clock(unsigned int ms)
|
||||||
} else if (::memcmp(m_buffer, "RPTCL", 5U) == 0) {
|
} else if (::memcmp(m_buffer, "RPTCL", 5U) == 0) {
|
||||||
::LogMessage("MMDVM Network, The connected MMDVM is closing down");
|
::LogMessage("MMDVM Network, The connected MMDVM is closing down");
|
||||||
} else if (::memcmp(m_buffer, "RPTC", 4U) == 0) {
|
} else if (::memcmp(m_buffer, "RPTC", 4U) == 0) {
|
||||||
|
// XXX FIXME !!!
|
||||||
m_configLen = length - 8U;
|
m_configLen = length - 8U;
|
||||||
m_configData = new unsigned char[m_configLen];
|
m_configData = new unsigned char[m_configLen];
|
||||||
::memcpy(m_configData, m_buffer + 8U, 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);
|
::memcpy(ack + 6U, m_netId, 4U);
|
||||||
m_socket.write(ack, 10U, m_rptAddr, m_rptAddrLen);
|
m_socket.write(ack, 10U, m_rptAddr, m_rptAddrLen);
|
||||||
} else if (::memcmp(m_buffer, "RPTO", 4U) == 0) {
|
} else if (::memcmp(m_buffer, "RPTO", 4U) == 0) {
|
||||||
m_options = std::string((char*)(m_buffer + 8U), length - 8U);
|
|
||||||
|
|
||||||
unsigned char ack[10U];
|
unsigned char ack[10U];
|
||||||
::memcpy(ack + 0U, "RPTACK", 6U);
|
::memcpy(ack + 0U, "RPTACK", 6U);
|
||||||
::memcpy(ack + 6U, m_netId, 4U);
|
::memcpy(ack + 6U, m_netId, 4U);
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,7 @@ public:
|
||||||
CMMDVMNetworkOld(const std::string& rptAddress, unsigned int rptPort, const std::string& localAddress, unsigned int localPort, bool debug);
|
CMMDVMNetworkOld(const std::string& rptAddress, unsigned int rptPort, const std::string& localAddress, unsigned int localPort, bool debug);
|
||||||
virtual ~CMMDVMNetworkOld();
|
virtual ~CMMDVMNetworkOld();
|
||||||
|
|
||||||
virtual std::string getOptions() const;
|
virtual unsigned int getShortConfig(unsigned char* config) const;
|
||||||
|
|
||||||
virtual unsigned int getConfig(unsigned char* config) const;
|
|
||||||
|
|
||||||
virtual unsigned int getId() const;
|
virtual unsigned int getId() const;
|
||||||
|
|
||||||
|
|
@ -66,7 +64,6 @@ private:
|
||||||
CUDPSocket m_socket;
|
CUDPSocket m_socket;
|
||||||
unsigned char* m_buffer;
|
unsigned char* m_buffer;
|
||||||
CRingBuffer<unsigned char> m_rxData;
|
CRingBuffer<unsigned char> m_rxData;
|
||||||
std::string m_options;
|
|
||||||
unsigned char* m_configData;
|
unsigned char* m_configData;
|
||||||
unsigned int m_configLen;
|
unsigned int m_configLen;
|
||||||
unsigned char* m_radioPositionData;
|
unsigned char* m_radioPositionData;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue