TGID & TS Transcoding WORKS!!!

This commit is contained in:
Cort Buffington 2016-11-16 14:48:40 -06:00
parent 1a1510714c
commit 490e6ef6f9
2 changed files with 26 additions and 18 deletions

View File

@ -193,7 +193,7 @@ def encode_emblc(_lc):
emblc_e.extend([_binlc[14],_binlc[30],_binlc[46],_binlc[62],_binlc[78],_binlc[94],_binlc[110],_binlc[126]])
emblc_e.extend([_binlc[15],_binlc[31],_binlc[47],_binlc[63],_binlc[79],_binlc[95],_binlc[111],_binlc[127]])
return({2: emblc_b, 3: emblc_c, 4: emblc_d, 5: emblc_e})
return({1: emblc_b, 2: emblc_c, 3: emblc_d, 4: emblc_e})
#------------------------------------------------------------------------------
# Used to execute the module directly to run built-in tests

View File

@ -88,13 +88,14 @@ class routerSYSTEM(HBSYSTEM):
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
'RX_LC': '\x00',
'TX_LC': '\x00',
'RX_LC': '\x00',
'TX_H_LC': '\x00',
'TX_T_LC': '\x00',
'TX_EMB_LC': {
1: '\x00',
2: '\x00',
3: '\x00',
4: '\x00',
5: '\x00',
}
},
2: {
@ -105,20 +106,21 @@ class routerSYSTEM(HBSYSTEM):
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
'RX_LC': '\x00',
'TX_LC': '\x00',
'RX_LC': '\x00',
'TX_H_LC': '\x00',
'TX_T_LC': '\x00',
'TX_EMB_LC': {
1: '\x00',
2: '\x00',
3: '\x00',
4: '\x00',
5: '\x00',
}
}
}
def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
pkt_time = time()
dmrpkt = _data[20:54]
dmrpkt = _data[20:53]
_bits = int_id(_data[15])
if _call_type == 'group':
@ -161,7 +163,7 @@ class routerSYSTEM(HBSYSTEM):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD:
logger.info('(%s) Call not routed, target active or in group hangtime: HBP system %s, TS%s, TGID%s', self._system, _target, _slot, int_id(rule['DST_GROUP']))
continue
if (rule['DST_GROUP'] == self.STATUS[_slot]['TX_TGID']) and (_stream_id != self.STATUS[_slot]['TX_STREAM_ID']) and ((pkt_time - _status[_slot]['TX_TIME']) < const.STREAM_TO):
if (rule['DST_GROUP'] == self.STATUS[_slot]['TX_TGID']) and (_stream_id != self.STATUS[_slot]['TX_STREAM_ID']) and ((pkt_time - self.STATUS[_slot]['TX_TIME']) < const.STREAM_TO):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD:
logger.info('(%s) Call not routed, call bridge in progress from %s, target: HBP system %s, TS%s, TGID%s', self._system, int_id(_src_sub), _target, _slot, int_id(rule['DST_GROUP']))
continue
@ -174,9 +176,10 @@ class routerSYSTEM(HBSYSTEM):
_target_status[_slot]['TX_TGID'] = rule['DST_GROUP']
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
# Generate LCs (full and EMB) for the TX stream
if _dst_id != rule['DST_GROUP']:
if True: #_dst_id != rule['DST_GROUP']:
dst_lc = self.STATUS[_slot]['RX_LC'][0:3] + rule['DST_GROUP'] + _rf_src
_target_status[_slot]['TX_LC'] = bptc.encode_header_lc(dst_lc)
_target_status[_slot]['TX_H_LC'] = bptc.encode_header_lc(dst_lc)
_target_status[_slot]['TX_T_LC'] = bptc.encode_terminator_lc(dst_lc)
_target_status[_slot]['TX_EMB_LC'] = bptc.encode_emblc(dst_lc)
logger.debug('(%s) Packet DST TGID (%s) does not match SRC TGID(%s) - Generating FULL and EMB LCs', self._system, int_id(rule['DST_GROUP']), int_id(_dst_id))
@ -191,15 +194,20 @@ class routerSYSTEM(HBSYSTEM):
# MUST TEST FOR NEW STREAM AND IF SO, RE-WRITE THE LC FOR THE TARGET
# MUST RE-WRITE DESTINATION TGID IF DIFFERENT
if _dst_id != rule['DST_GROUP']:
if True: #_dst_id != rule['DST_GROUP']:
dmrbits = bitarray(endian='big')
dmrbits.frombytes(dmrpkt)
# Create a voice header packet (FULL LC)
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD:
pass # build a new DMR voice header packet with the TX Full LC
dmrbits = _target_status[_slot]['TX_H_LC'][0:98] + dmrbits[98:166] + _target_status[_slot]['TX_H_LC'][98:197]
# Create a voice terminator packet (FULL LC)
elif _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VTERM:
pass # build a new DMR voice terminator packet with the TX Full LC
elif _dtype_vseq in [2,3,4,5]:
pass # build a new DMR voice packet for burst B,C,D,E based on EMB LC
_tmp_data = _tmp_data + dmrpkt
dmrbits = _target_status[_slot]['TX_T_LC'][0:98] + dmrbits[98:166] + _target_status[_slot]['TX_T_LC'][98:197]
# Create a Burst B-E packet (Embedded LC)
elif _dtype_vseq in [1,2,3,4]:
dmrbits = dmrbits[0:116] + _target_status[_slot]['TX_EMB_LC'][_dtype_vseq] + dmrbits[148:264]
dmrpkt = dmrbits.tobytes()
_tmp_data = _tmp_data + dmrpkt + _data[53:55]
# Transmit the packet to the destination system
systems[_target].send_system(_tmp_data)