mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-22 22:45:36 +08:00
Add two more rewrite types.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user