From c2bcec4a59a5b28f142a55d0b2119818d7eb5b96 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 24 May 2017 17:46:07 +0100 Subject: [PATCH] Modify Type Rewrite to handle BM Echo. --- Conf.cpp | 8 ++++---- Conf.h | 4 ++-- DMRGateway.cpp | 12 ++++++------ DMRGateway.ini | 5 +++-- RewriteType.cpp | 16 +++++++--------- RewriteType.h | 6 +++--- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 189818a..032fe77 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -242,9 +242,9 @@ bool CConf::read() if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) { CTypeRewriteStruct rewrite; rewrite.m_fromSlot = ::atoi(p1); - rewrite.m_fromId = ::atoi(p2); + rewrite.m_fromTG = ::atoi(p2); rewrite.m_toSlot = ::atoi(p3); - rewrite.m_toTG = ::atoi(p4); + rewrite.m_toId = ::atoi(p4); m_dmrNetwork1TypeRewrites.push_back(rewrite); } } else if (::strcmp(key, "SrcRewrite") == 0) { @@ -318,9 +318,9 @@ bool CConf::read() if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL) { CTypeRewriteStruct rewrite; rewrite.m_fromSlot = ::atoi(p1); - rewrite.m_fromId = ::atoi(p2); + rewrite.m_fromTG = ::atoi(p2); rewrite.m_toSlot = ::atoi(p3); - rewrite.m_toTG = ::atoi(p4); + rewrite.m_toId = ::atoi(p4); m_dmrNetwork2TypeRewrites.push_back(rewrite); } } else if (::strcmp(key, "SrcRewrite") == 0) { diff --git a/Conf.h b/Conf.h index a2bac18..1019bb4 100644 --- a/Conf.h +++ b/Conf.h @@ -40,9 +40,9 @@ struct CPCRewriteStruct { struct CTypeRewriteStruct { unsigned int m_fromSlot; - unsigned int m_fromId; + unsigned int m_fromTG; unsigned int m_toSlot; - unsigned int m_toTG; + unsigned int m_toId; }; struct CSrcRewriteStruct { diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 8f33324..7bacb8d 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -659,11 +659,11 @@ bool CDMRGateway::createDMRNetwork1() std::vector typeRewrites = m_conf.getDMRNetwork1TypeRewrites(); for (std::vector::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); + LogInfo(" Rewrite RF: %u:TG%u -> %u:%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toId); - CRewriteType* rewrite = new CRewriteType("DMR-1", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG); + CRewriteType* rewrite = new CRewriteType("DMR-1", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toId); - m_dmr1NetRewrites.push_back(rewrite); + m_dmr1RFRewrites.push_back(rewrite); } std::vector srcRewrites = m_conf.getDMRNetwork1SrcRewrites(); @@ -748,11 +748,11 @@ bool CDMRGateway::createDMRNetwork2() std::vector typeRewrites = m_conf.getDMRNetwork2TypeRewrites(); for (std::vector::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); + LogInfo(" Rewrite RF: %u:TG%u -> %u:%u", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toId); - CRewriteType* rewrite = new CRewriteType("DMR-2", (*it).m_fromSlot, (*it).m_fromId, (*it).m_toSlot, (*it).m_toTG); + CRewriteType* rewrite = new CRewriteType("DMR-2", (*it).m_fromSlot, (*it).m_fromTG, (*it).m_toSlot, (*it).m_toId); - m_dmr2NetRewrites.push_back(rewrite); + m_dmr2RFRewrites.push_back(rewrite); } std::vector srcRewrites = m_conf.getDMRNetwork2SrcRewrites(); diff --git a/DMRGateway.ini b/DMRGateway.ini index 502c144..d10da29 100644 --- a/DMRGateway.ini +++ b/DMRGateway.ini @@ -42,8 +42,9 @@ TGRewrite=1,9,1,9,1 TGRewrite=2,9,2,9,1 # Reflector control command slot 2 94000->4000 to 95000->5000 PCRewrite=2,94000,2,4000,1001 -# Echo on slot 1 9990 -PCRewrite=1,9990,2,9990,1 +# Echo on RF slot 1 TG9990 to network slot 1 9990 +TypeRewrite=1,9990,1,9990 +SrcRewrite=1,9990,1,9990,1 # Reflector status returns SrcRewrite=2,4000,2,9,1001 Password=PASSWORD diff --git a/RewriteType.cpp b/RewriteType.cpp index 156f510..e7251a4 100644 --- a/RewriteType.cpp +++ b/RewriteType.cpp @@ -25,13 +25,13 @@ #include #include -CRewriteType::CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG) : +CRewriteType::CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromTG, unsigned int toSlot, unsigned int toId) : m_name(name), m_fromSlot(fromSlot), -m_fromId(fromId), +m_fromTG(fromTG), m_toSlot(toSlot), -m_toTG(toTG), -m_lc(FLCO_GROUP, 0U, toTG), +m_toId(toId), +m_lc(FLCO_USER_USER, 0U, toId), m_embeddedLC() { assert(fromSlot == 1U || fromSlot == 2U); @@ -48,14 +48,14 @@ bool CRewriteType::process(CDMRData& data) unsigned int dstId = data.getDstId(); unsigned int slotNo = data.getSlotNo(); - if (flco != FLCO_USER_USER || slotNo != m_fromSlot || dstId != m_fromId) + if (flco != FLCO_GROUP || slotNo != m_fromSlot || dstId != m_fromTG) return false; if (m_fromSlot != m_toSlot) data.setSlotNo(m_toSlot); - data.setDstId(m_toTG); - data.setFLCO(FLCO_GROUP); + data.setDstId(m_toId); + data.setFLCO(FLCO_USER_USER); unsigned char dataType = data.getDataType(); @@ -86,8 +86,6 @@ void CRewriteType::processHeader(CDMRData& data, unsigned char dataType) 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); diff --git a/RewriteType.h b/RewriteType.h index 5730848..ac47b87 100644 --- a/RewriteType.h +++ b/RewriteType.h @@ -26,7 +26,7 @@ class CRewriteType : public IRewrite { public: - CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromId, unsigned int toSlot, unsigned int toTG); + CRewriteType(const char* name, unsigned int fromSlot, unsigned int fromTG, unsigned int toSlot, unsigned int toId); virtual ~CRewriteType(); virtual bool process(CDMRData& data); @@ -34,9 +34,9 @@ public: private: const char* m_name; unsigned int m_fromSlot; - unsigned int m_fromId; + unsigned int m_fromTG; unsigned int m_toSlot; - unsigned int m_toTG; + unsigned int m_toId; CDMRLC m_lc; CDMREmbeddedData m_embeddedLC;