Add two more rewrite types.

This commit is contained in:
Jonathan Naylor
2017-05-15 21:16:52 +01:00
parent 1e5d387d81
commit f92ec4263f
16 changed files with 543 additions and 60 deletions

View File

@@ -61,6 +61,8 @@ m_dmrNetwork1Password(),
m_dmrNetwork1Debug(false),
m_dmrNetwork1TGRewrites(),
m_dmrNetwork1PCRewrites(),
m_dmrNetwork1TypeRewrites(),
m_dmrNetwork1SrcRewrites(),
m_dmrNetwork2Enabled(false),
m_dmrNetwork2Id(0U),
m_dmrNetwork2Address(),
@@ -70,6 +72,8 @@ m_dmrNetwork2Password(),
m_dmrNetwork2Debug(false),
m_dmrNetwork2TGRewrites(),
m_dmrNetwork2PCRewrites(),
m_dmrNetwork2TypeRewrites(),
m_dmrNetwork2SrcRewrites(),
m_xlxNetworkEnabled(false),
m_xlxNetworkId(0U),
m_xlxNetworkAddress(),
@@ -200,13 +204,15 @@ bool CConf::read()
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
char* p4 = ::strtok(NULL, ", ");
char* p5 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL) {
CTGRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromTG = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
rewrite.m_range = ::atoi(p5);
m_dmrNetwork1TGRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "PCRewrite") == 0) {
@@ -224,6 +230,32 @@ bool CConf::read()
rewrite.m_range = ::atoi(p5);
m_dmrNetwork1PCRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "TypeRewrite") == 0) {
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
CTypeRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromId = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
m_dmrNetwork1TypeRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "SrcRewrite") == 0) {
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
CSrcRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromId = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
m_dmrNetwork1SrcRewrites.push_back(rewrite);
}
}
} else if (section == SECTION_DMR_NETWORK_2) {
if (::strcmp(key, "Enabled") == 0)
@@ -244,13 +276,15 @@ bool CConf::read()
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
char* p4 = ::strtok(NULL, ", ");
char* p5 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL) {
CTGRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromTG = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
rewrite.m_range = ::atoi(p5);
m_dmrNetwork2TGRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "PCRewrite") == 0) {
@@ -268,6 +302,32 @@ bool CConf::read()
rewrite.m_range = ::atoi(p5);
m_dmrNetwork2PCRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "TypeRewrite") == 0) {
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
CTypeRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromId = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
m_dmrNetwork2TypeRewrites.push_back(rewrite);
}
} else if (::strcmp(key, "SrcRewrite") == 0) {
char* p1 = ::strtok(value, ", ");
char* p2 = ::strtok(NULL, ", ");
char* p3 = ::strtok(NULL, ", ");
char* p4 = ::strtok(NULL, " \r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) {
CSrcRewriteStruct rewrite;
rewrite.m_fromSlot = ::atoi(p1);
rewrite.m_fromId = ::atoi(p2);
rewrite.m_toSlot = ::atoi(p3);
rewrite.m_toTG = ::atoi(p4);
m_dmrNetwork2SrcRewrites.push_back(rewrite);
}
}
}
}
@@ -442,6 +502,16 @@ std::vector<CPCRewriteStruct> CConf::getDMRNetwork1PCRewrites() const
return m_dmrNetwork1PCRewrites;
}
std::vector<CTypeRewriteStruct> CConf::getDMRNetwork1TypeRewrites() const
{
return m_dmrNetwork1TypeRewrites;
}
std::vector<CSrcRewriteStruct> CConf::getDMRNetwork1SrcRewrites() const
{
return m_dmrNetwork1SrcRewrites;
}
bool CConf::getDMRNetwork2Enabled() const
{
return m_dmrNetwork2Enabled;
@@ -486,3 +556,13 @@ std::vector<CPCRewriteStruct> CConf::getDMRNetwork2PCRewrites() const
{
return m_dmrNetwork2PCRewrites;
}
std::vector<CTypeRewriteStruct> CConf::getDMRNetwork2TypeRewrites() const
{
return m_dmrNetwork2TypeRewrites;
}
std::vector<CSrcRewriteStruct> CConf::getDMRNetwork2SrcRewrites() const
{
return m_dmrNetwork2SrcRewrites;
}

23
Conf.h
View File

@@ -27,6 +27,7 @@ struct CTGRewriteStruct {
unsigned int m_fromTG;
unsigned int m_toSlot;
unsigned int m_toTG;
unsigned int m_range;
};
struct CPCRewriteStruct {
@@ -37,6 +38,20 @@ struct CPCRewriteStruct {
unsigned int m_range;
};
struct CTypeRewriteStruct {
unsigned int m_fromSlot;
unsigned int m_fromId;
unsigned int m_toSlot;
unsigned int m_toTG;
};
struct CSrcRewriteStruct {
unsigned int m_fromSlot;
unsigned int m_fromId;
unsigned int m_toSlot;
unsigned int m_toTG;
};
class CConf
{
public:
@@ -75,6 +90,8 @@ public:
bool getDMRNetwork1Debug() const;
std::vector<CTGRewriteStruct> getDMRNetwork1TGRewrites() const;
std::vector<CPCRewriteStruct> getDMRNetwork1PCRewrites() const;
std::vector<CTypeRewriteStruct> getDMRNetwork1TypeRewrites() const;
std::vector<CSrcRewriteStruct> getDMRNetwork1SrcRewrites() const;
// The DMR Network 2 section
bool getDMRNetwork2Enabled() const;
@@ -86,6 +103,8 @@ public:
bool getDMRNetwork2Debug() const;
std::vector<CTGRewriteStruct> getDMRNetwork2TGRewrites() const;
std::vector<CPCRewriteStruct> getDMRNetwork2PCRewrites() const;
std::vector<CTypeRewriteStruct> getDMRNetwork2TypeRewrites() const;
std::vector<CSrcRewriteStruct> getDMRNetwork2SrcRewrites() const;
// The XLX Network section
bool getXLXNetworkEnabled() const;
@@ -127,6 +146,8 @@ private:
bool m_dmrNetwork1Debug;
std::vector<CTGRewriteStruct> m_dmrNetwork1TGRewrites;
std::vector<CPCRewriteStruct> m_dmrNetwork1PCRewrites;
std::vector<CTypeRewriteStruct> m_dmrNetwork1TypeRewrites;
std::vector<CSrcRewriteStruct> m_dmrNetwork1SrcRewrites;
bool m_dmrNetwork2Enabled;
unsigned int m_dmrNetwork2Id;
@@ -137,6 +158,8 @@ private:
bool m_dmrNetwork2Debug;
std::vector<CTGRewriteStruct> m_dmrNetwork2TGRewrites;
std::vector<CPCRewriteStruct> m_dmrNetwork2PCRewrites;
std::vector<CTypeRewriteStruct> m_dmrNetwork2TypeRewrites;
std::vector<CSrcRewriteStruct> m_dmrNetwork2SrcRewrites;
bool m_xlxNetworkEnabled;
unsigned int m_xlxNetworkId;

View File

@@ -16,10 +16,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "RewriteType.h"
#include "RewriteSrc.h"
#include "DMRGateway.h"
#include "Version.h"
#include "StopWatch.h"
#include "RewritePC.h"
#include "Version.h"
#include "Thread.h"
#include "Voice.h"
#include "Log.h"
@@ -607,24 +609,41 @@ bool CDMRGateway::createDMRNetwork1()
std::vector<CTGRewriteStruct> tgRewrites = m_conf.getDMRNetwork1TGRewrites();
for (std::vector<CTGRewriteStruct>::const_iterator it = tgRewrites.begin(); it != tgRewrites.end(); ++it) {
LogInfo(" TG Rewrite: %u:%u -> %u:%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG);
LogInfo(" Rewrite RF: %u:TG%u-TG%u -> %u:TG%u-TG%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_fromTG + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toTG, (*it).m_toTG + (*it).m_range - 1U);
LogInfo(" Rewrite Net: %u:TG%u-TG%u -> %u:TG%u-TG%u", (*it).m_toSlot, (*it).m_toTG, (*it).m_toTG + (*it).m_range - 1U, (*it).m_fromSlot, (*it).m_fromTG, (*it).m_fromTG + (*it).m_range - 1U);
CRewriteTG* netTGRewrite = new CRewriteTG((*it).m_toSlot, (*it).m_toTG, (*it).m_fromSlot, (*it).m_fromTG);
CRewriteTG* rfTGRewrite = new CRewriteTG((*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG);
CRewriteTG* rfRewrite = new CRewriteTG("DMR-1", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG, (*it).m_range);
CRewriteTG* netRewrite = new CRewriteTG("DMR-1", (*it).m_toSlot, (*it).m_toTG, (*it).m_fromSlot, (*it).m_fromTG, (*it).m_range);
m_dmr1NetRewrites.push_back(netTGRewrite);
m_dmr1RFRewrites.push_back(rfTGRewrite);
m_dmr1RFRewrites.push_back(rfRewrite);
m_dmr1NetRewrites.push_back(netRewrite);
}
std::vector<CPCRewriteStruct> pcRewrites = m_conf.getDMRNetwork1PCRewrites();
for (std::vector<CPCRewriteStruct>::const_iterator it = pcRewrites.begin(); it != pcRewrites.end(); ++it) {
LogInfo(" PC Rewrite: %u:%u-%u -> %u:%u-%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_fromId + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toId, (*it).m_toId + (*it).m_range - 1U);
LogInfo(" Rewrite RF: %u:%u-%u -> %u:%u-%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_fromId + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toId, (*it).m_toId + (*it).m_range - 1U);
CRewritePC* netPCRewrite = new CRewritePC((*it).m_toSlot, (*it).m_toId, (*it).m_fromSlot, (*it).m_fromId, (*it).m_range);
CRewritePC* rfPCRewrite = new CRewritePC((*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toId, (*it).m_range);
CRewritePC* rewrite = new CRewritePC("DMR-1", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toId, (*it).m_range);
m_dmr1NetRewrites.push_back(netPCRewrite);
m_dmr1RFRewrites.push_back(rfPCRewrite);
m_dmr1RFRewrites.push_back(rewrite);
}
std::vector<CTypeRewriteStruct> typeRewrites = m_conf.getDMRNetwork1TypeRewrites();
for (std::vector<CTypeRewriteStruct>::const_iterator it = typeRewrites.begin(); it != typeRewrites.end(); ++it) {
LogInfo(" Rewrite Net: %u:%u -> %u:TG%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
CRewriteType* rewrite = new CRewriteType("DMR-1", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
m_dmr1NetRewrites.push_back(rewrite);
}
std::vector<CSrcRewriteStruct> srcRewrites = m_conf.getDMRNetwork1SrcRewrites();
for (std::vector<CSrcRewriteStruct>::const_iterator it = srcRewrites.begin(); it != srcRewrites.end(); ++it) {
LogInfo(" Rewrite Net: %u:%u -> %u:TG%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
CRewriteSrc* rewrite = new CRewriteSrc("DMR-1", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
m_dmr1NetRewrites.push_back(rewrite);
}
return true;
@@ -673,24 +692,41 @@ bool CDMRGateway::createDMRNetwork2()
std::vector<CTGRewriteStruct> tgRewrites = m_conf.getDMRNetwork2TGRewrites();
for (std::vector<CTGRewriteStruct>::const_iterator it = tgRewrites.begin(); it != tgRewrites.end(); ++it) {
LogInfo(" TG Rewrite: %u:%u -> %u:%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG);
LogInfo(" Rewrite RF: %u:TG%u-TG%u -> %u:TG%u-TG%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_fromTG + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toTG, (*it).m_toTG + (*it).m_range - 1U);
LogInfo(" Rewrite Net: %u:TG%u-TG%u -> %u:TG%u-TG%u", (*it).m_toSlot, (*it).m_toTG, (*it).m_toTG + (*it).m_range - 1U, (*it).m_fromSlot, (*it).m_fromTG, (*it).m_fromTG + (*it).m_range - 1U);
CRewriteTG* netTGRewrite = new CRewriteTG((*it).m_toSlot, (*it).m_toTG, (*it).m_fromSlot, (*it).m_fromTG);
CRewriteTG* rfTGRewrite = new CRewriteTG((*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG);
CRewriteTG* rfRewrite = new CRewriteTG("DMR-2", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toTG, (*it).m_range);
CRewriteTG* netRewrite = new CRewriteTG("DMR-2", (*it).m_toSlot, (*it).m_toTG, (*it).m_fromSlot, (*it).m_fromTG, (*it).m_range);
m_dmr2NetRewrites.push_back(netTGRewrite);
m_dmr2RFRewrites.push_back(rfTGRewrite);
m_dmr2RFRewrites.push_back(rfRewrite);
m_dmr2NetRewrites.push_back(netRewrite);
}
std::vector<CPCRewriteStruct> pcRewrites = m_conf.getDMRNetwork2PCRewrites();
for (std::vector<CPCRewriteStruct>::const_iterator it = pcRewrites.begin(); it != pcRewrites.end(); ++it) {
LogInfo(" PC Rewrite: %u:%u-%u -> %u:%u-%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_fromId + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toId, (*it).m_toId + (*it).m_range - 1U);
LogInfo(" Rewrite RF: %u:%u-%u -> %u:%u-%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_fromId + (*it).m_range - 1U, (*it).m_toSlot, (*it).m_toId, (*it).m_toId + (*it).m_range - 1U);
CRewritePC* netPCRewrite = new CRewritePC((*it).m_toSlot, (*it).m_toId, (*it).m_fromSlot, (*it).m_fromId, (*it).m_range);
CRewritePC* rfPCRewrite = new CRewritePC((*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toId, (*it).m_range);
CRewritePC* rewrite = new CRewritePC("DMR-2", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toId, (*it).m_range);
m_dmr2NetRewrites.push_back(netPCRewrite);
m_dmr2RFRewrites.push_back(rfPCRewrite);
m_dmr2RFRewrites.push_back(rewrite);
}
std::vector<CTypeRewriteStruct> typeRewrites = m_conf.getDMRNetwork2TypeRewrites();
for (std::vector<CTypeRewriteStruct>::const_iterator it = typeRewrites.begin(); it != typeRewrites.end(); ++it) {
LogInfo(" Rewrite Net: %u:%u -> %u:TG%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
CRewriteType* rewrite = new CRewriteType("DMR-2", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
m_dmr2NetRewrites.push_back(rewrite);
}
std::vector<CSrcRewriteStruct> srcRewrites = m_conf.getDMRNetwork2SrcRewrites();
for (std::vector<CSrcRewriteStruct>::const_iterator it = srcRewrites.begin(); it != srcRewrites.end(); ++it) {
LogInfo(" Rewrite Net: %u:%u -> %u:TG%u", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
CRewriteSrc* rewrite = new CRewriteSrc("DMR-2", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG);
m_dmr2NetRewrites.push_back(rewrite);
}
return true;
@@ -743,8 +779,8 @@ bool CDMRGateway::createXLXNetwork()
LogInfo(" Slot: %u", m_xlxSlot);
LogInfo(" TG: %u", m_xlxTG);
m_rptRewrite = new CRewriteTG(XLX_SLOT, XLX_TG, m_xlxSlot, m_xlxTG);
m_xlxRewrite = new CRewriteTG(m_xlxSlot, m_xlxTG, XLX_SLOT, XLX_TG);
m_rptRewrite = new CRewriteTG("XLX", XLX_SLOT, XLX_TG, m_xlxSlot, m_xlxTG, 1U);
m_xlxRewrite = new CRewriteTG("XLX", m_xlxSlot, m_xlxTG, XLX_SLOT, XLX_TG, 1U);
return true;
}

View File

@@ -35,17 +35,21 @@ Enabled=1
Address=44.131.4.1
Port=62031
# Local=3352
TGRewrite=1,9,1,9
TGRewrite=1,9,1,9,1
PCRewrite=2,4000,2,4000,1000
SrcRewrite=2,12345,2,9
Password=PASSWORD
Debug=0
[DMR Network 2]
Enabled=0
Address=44.131.4.1
Port=62031
Port=55555
# Local=3352
TGRewrite=2,9,2,9
TGRewrite=2,9,2,9,1
PCRewrite=2,6000,2,4000,1000
TypeRewrite=1,2351,1,2351
TypeRewrite=1,235,1,235
TypeRewrite=2,9,2,9
Password=PASSWORD
Debug=0

View File

@@ -166,7 +166,9 @@
<ClInclude Include="RepeaterProtocol.h" />
<ClInclude Include="Rewrite.h" />
<ClInclude Include="RewritePC.h" />
<ClInclude Include="RewriteSrc.h" />
<ClInclude Include="RewriteTG.h" />
<ClInclude Include="RewriteType.h" />
<ClInclude Include="RingBuffer.h" />
<ClInclude Include="RS129.h" />
<ClInclude Include="SHA256.h" />
@@ -199,7 +201,9 @@
<ClCompile Include="RepeaterProtocol.cpp" />
<ClCompile Include="Rewrite.cpp" />
<ClCompile Include="RewritePC.cpp" />
<ClCompile Include="RewriteSrc.cpp" />
<ClCompile Include="RewriteTG.cpp" />
<ClCompile Include="RewriteType.cpp" />
<ClCompile Include="RS129.cpp" />
<ClCompile Include="SHA256.cpp" />
<ClCompile Include="StopWatch.cpp" />

View File

@@ -107,6 +107,12 @@
<ClInclude Include="Rewrite.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RewriteSrc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RewriteType.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Conf.cpp">
@@ -196,5 +202,11 @@
<ClCompile Include="Rewrite.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RewriteSrc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RewriteType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -5,8 +5,8 @@ LIBS = -lpthread
LDFLAGS = -g
OBJECTS = BPTC19696.o Conf.o CRC.o DMRData.o DMREmbeddedData.o DMREMB.o DMRFullLC.o DMRGateway.o DMRLC.o DMRNetwork.o DMRSlotType.o Golay2087.o Hamming.o Log.o \
MMDVMNetwork.o QR1676.o RepeaterProtocol.o Rewrite.o RewritePC.o RewriteTG.o RS129.o SHA256.o StopWatch.o Sync.o Thread.o Timer.o UDPSocket.o Utils.o \
Voice.o
MMDVMNetwork.o QR1676.o RepeaterProtocol.o Rewrite.o RewritePC.o RewriteSrc.o RewriteTG.o RewriteType.o RS129.o SHA256.o StopWatch.o Sync.o \
Thread.o Timer.o UDPSocket.o Utils.o Voice.o
all: DMRGateway

View File

@@ -24,7 +24,8 @@
#include <cstdio>
#include <cassert>
CRewritePC::CRewritePC(unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toId, unsigned int range) :
CRewritePC::CRewritePC(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toId, unsigned int range) :
m_name(name),
m_fromSlot(fromSlot),
m_fromIdStart(fromId),
m_fromIdEnd(fromId + range),

View File

@@ -26,12 +26,13 @@
class CRewritePC : public IRewrite {
public:
CRewritePC(unsigned int fromSLot, unsigned int fromId, unsigned int toSlot, unsigned int toId, unsigned int range);
CRewritePC(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toId, unsigned int range);
virtual ~CRewritePC();
virtual bool process(CDMRData& data);
private:
const char* m_name;
unsigned int m_fromSlot;
unsigned int m_fromIdStart;
unsigned int m_fromIdEnd;

103
RewriteSrc.cpp Normal file
View File

@@ -0,0 +1,103 @@
/*
* Copyright (C) 2017 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 "RewriteSrc.h"
#include "DMRDefines.h"
#include "DMRFullLC.h"
#include "Log.h"
#include <cstdio>
#include <cassert>
CRewriteSrc::CRewriteSrc(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG) :
m_name(name),
m_fromSlot(fromSlot),
m_fromId(fromId),
m_toSlot(toSlot),
m_toTG(toTG),
m_lc(FLCO_GROUP, fromId, toTG),
m_embeddedLC()
{
assert(fromSlot == 1U || fromSlot == 2U);
assert(toSlot == 1U || toSlot == 2U);
m_embeddedLC.setLC(m_lc);
}
CRewriteSrc::~CRewriteSrc()
{
}
bool CRewriteSrc::process(CDMRData& data)
{
FLCO flco = data.getFLCO();
unsigned int srcId = data.getSrcId();
unsigned int slotNo = data.getSlotNo();
if (flco != FLCO_USER_USER || slotNo != m_fromSlot || srcId != m_fromId)
return false;
if (m_fromSlot != m_toSlot)
data.setSlotNo(m_toSlot);
data.setDstId(m_toTG);
data.setFLCO(FLCO_GROUP);
unsigned char dataType = data.getDataType();
switch (dataType) {
case DT_VOICE_LC_HEADER:
case DT_TERMINATOR_WITH_LC:
processHeader(data, dataType);
break;
case DT_VOICE:
processVoice(data);
break;
case DT_VOICE_SYNC:
// Nothing to do
break;
default:
// Not sure what to do
break;
}
return true;
}
void CRewriteSrc::processHeader(CDMRData& data, unsigned char dataType)
{
unsigned char buffer[DMR_FRAME_LENGTH_BYTES];
data.getData(buffer);
CDMRFullLC fullLC;
fullLC.encode(m_lc, buffer, dataType);
data.setData(buffer);
}
void CRewriteSrc::processVoice(CDMRData& data)
{
unsigned char buffer[DMR_FRAME_LENGTH_BYTES];
data.getData(buffer);
unsigned char n = data.getN();
m_embeddedLC.getData(buffer, n);
data.setData(buffer);
}

48
RewriteSrc.h Normal file
View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2017 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.
*/
#if !defined(REWRITESRC_H)
#define REWRITESRC_H
#include "DMREmbeddedData.h"
#include "Rewrite.h"
#include "DMRData.h"
#include "DMRLC.h"
class CRewriteSrc : public IRewrite {
public:
CRewriteSrc(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG);
virtual ~CRewriteSrc();
virtual bool process(CDMRData& data);
private:
const char* m_name;
unsigned int m_fromSlot;
unsigned int m_fromId;
unsigned int m_toSlot;
unsigned int m_toTG;
CDMRLC m_lc;
CDMREmbeddedData m_embeddedLC;
void processHeader(CDMRData& data, unsigned char dataType);
void processVoice(CDMRData& data);
};
#endif

View File

@@ -24,11 +24,13 @@
#include <cstdio>
#include <cassert>
CRewriteTG::CRewriteTG(unsigned int fromSlot, unsigned int fromTG, unsigned int toSlot, unsigned int toTG) :
CRewriteTG::CRewriteTG(const char* name, unsigned int fromSlot, unsigned int fromTG, unsigned int toSlot, unsigned int toTG, unsigned int range) :
m_name(name),
m_fromSlot(fromSlot),
m_fromTG(fromTG),
m_fromTGStart(fromTG),
m_fromTGEnd(fromTG + range),
m_toSlot(toSlot),
m_toTG(toTG),
m_toTGStart(toTG),
m_lc(FLCO_GROUP, 0U, toTG),
m_embeddedLC()
{
@@ -46,24 +48,26 @@ bool CRewriteTG::process(CDMRData& data)
unsigned int dstId = data.getDstId();
unsigned int slotNo = data.getSlotNo();
if (flco != FLCO_GROUP || slotNo != m_fromSlot || dstId != m_fromTG)
if (flco != FLCO_GROUP || slotNo != m_fromSlot || dstId < m_fromTGStart || dstId >= m_fromTGEnd)
return false;
if (m_fromSlot != m_toSlot)
data.setSlotNo(m_toSlot);
if (m_fromTG != m_toTG) {
data.setDstId(m_toTG);
if (m_fromTGStart != m_toTGStart) {
unsigned int newTG = dstId + m_toTGStart - m_fromTGStart;
data.setDstId(newTG);
unsigned char dataType = data.getDataType();
switch (dataType) {
case DT_VOICE_LC_HEADER:
case DT_TERMINATOR_WITH_LC:
processHeader(data, dataType);
processHeader(data, newTG, dataType);
break;
case DT_VOICE:
processVoice(data);
processVoice(data, newTG);
break;
case DT_VOICE_SYNC:
// Nothing to do
@@ -77,11 +81,12 @@ bool CRewriteTG::process(CDMRData& data)
return true;
}
void CRewriteTG::processHeader(CDMRData& data, unsigned char dataType)
void CRewriteTG::processHeader(CDMRData& data, unsigned int tg, unsigned char dataType)
{
unsigned int srcId = data.getSrcId();
if (srcId != m_lc.getSrcId()) {
if (srcId != m_lc.getSrcId() || tg != m_lc.getDstId()) {
m_lc.setSrcId(srcId);
m_lc.setDstId(tg);
m_embeddedLC.setLC(m_lc);
}
@@ -94,11 +99,12 @@ void CRewriteTG::processHeader(CDMRData& data, unsigned char dataType)
data.setData(buffer);
}
void CRewriteTG::processVoice(CDMRData& data)
void CRewriteTG::processVoice(CDMRData& data, unsigned int tg)
{
unsigned int srcId = data.getSrcId();
if (srcId != m_lc.getSrcId()) {
if (srcId != m_lc.getSrcId() || tg != m_lc.getDstId()) {
m_lc.setSrcId(srcId);
m_lc.setDstId(tg);
m_embeddedLC.setLC(m_lc);
}

View File

@@ -26,21 +26,23 @@
class CRewriteTG : public IRewrite {
public:
CRewriteTG(unsigned int fromSLot, unsigned int fromTG, unsigned int toSlot, unsigned int toTG);
CRewriteTG(const char*name, unsigned int fromSlot, unsigned int fromTG, unsigned int toSlot, unsigned int toTG, unsigned int range);
virtual ~CRewriteTG();
virtual bool process(CDMRData& data);
private:
const char* m_name;
unsigned int m_fromSlot;
unsigned int m_fromTG;
unsigned int m_fromTGStart;
unsigned int m_fromTGEnd;
unsigned int m_toSlot;
unsigned int m_toTG;
unsigned int m_toTGStart;
CDMRLC m_lc;
CDMREmbeddedData m_embeddedLC;
void processHeader(CDMRData& data, unsigned char dataType);
void processVoice(CDMRData& data);
void processHeader(CDMRData& data, unsigned int tg, unsigned char dataType);
void processVoice(CDMRData& data, unsigned int tg);
};

115
RewriteType.cpp Normal file
View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2017 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 "RewriteType.h"
#include "DMRDefines.h"
#include "DMRFullLC.h"
#include "Log.h"
#include <cstdio>
#include <cassert>
CRewriteType::CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG) :
m_name(name),
m_fromSlot(fromSlot),
m_fromId(fromId),
m_toSlot(toSlot),
m_toTG(toTG),
m_lc(FLCO_GROUP, 0U, toTG),
m_embeddedLC()
{
assert(fromSlot == 1U || fromSlot == 2U);
assert(toSlot == 1U || toSlot == 2U);
}
CRewriteType::~CRewriteType()
{
}
bool CRewriteType::process(CDMRData& data)
{
FLCO flco = data.getFLCO();
unsigned int dstId = data.getDstId();
unsigned int slotNo = data.getSlotNo();
if (flco != FLCO_USER_USER || slotNo != m_fromSlot || dstId != m_fromId)
return false;
if (m_fromSlot != m_toSlot)
data.setSlotNo(m_toSlot);
data.setDstId(m_toTG);
data.setFLCO(FLCO_GROUP);
unsigned char dataType = data.getDataType();
switch (dataType) {
case DT_VOICE_LC_HEADER:
case DT_TERMINATOR_WITH_LC:
processHeader(data, dataType);
break;
case DT_VOICE:
processVoice(data);
break;
case DT_VOICE_SYNC:
// Nothing to do
break;
default:
// Not sure what to do
break;
}
return true;
}
void CRewriteType::processHeader(CDMRData& data, unsigned char dataType)
{
unsigned int srcId = data.getSrcId();
if (srcId != m_lc.getSrcId()) {
m_lc.setSrcId(srcId);
m_embeddedLC.setLC(m_lc);
}
LogDebug("%s, Private call to TG rewrite of id: %u", m_name, m_fromId);
unsigned char buffer[DMR_FRAME_LENGTH_BYTES];
data.getData(buffer);
CDMRFullLC fullLC;
fullLC.encode(m_lc, buffer, dataType);
data.setData(buffer);
}
void CRewriteType::processVoice(CDMRData& data)
{
unsigned int srcId = data.getSrcId();
if (srcId != m_lc.getSrcId()) {
m_lc.setSrcId(srcId);
m_embeddedLC.setLC(m_lc);
}
unsigned char buffer[DMR_FRAME_LENGTH_BYTES];
data.getData(buffer);
unsigned char n = data.getN();
m_embeddedLC.getData(buffer, n);
data.setData(buffer);
}

48
RewriteType.h Normal file
View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2017 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.
*/
#if !defined(REWRITETYPE_H)
#define REWRITETYPE_H
#include "DMREmbeddedData.h"
#include "Rewrite.h"
#include "DMRData.h"
#include "DMRLC.h"
class CRewriteType : public IRewrite {
public:
CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG);
virtual ~CRewriteType();
virtual bool process(CDMRData& data);
private:
const char* m_name;
unsigned int m_fromSlot;
unsigned int m_fromId;
unsigned int m_toSlot;
unsigned int m_toTG;
CDMRLC m_lc;
CDMREmbeddedData m_embeddedLC;
void processHeader(CDMRData& data, unsigned char dataType);
void processVoice(CDMRData& data);
};
#endif

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20170514";
const char* VERSION = "20170515";
#endif