confirmed FreeDMR group and unit call RX

This commit is contained in:
KF7EEL 2021-09-06 19:58:56 -07:00
parent 75625510c9
commit 88d4447bae
3 changed files with 55 additions and 29 deletions

View File

@ -352,9 +352,11 @@ def all_data(_data):
for system in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
print(CONFIG['SYSTEMS'][system]['OTHER_OPTIONS'])
if 'ALL_DATA' in CONFIG['SYSTEMS'][system]['OTHER_OPTIONS']:
print('mirrored to ' + system)
systems[system].send_system(_data)
print(SVRD + b'DATA' + _data)
systems[system].send_system(SVRD + b'DATA' + _data)
# Import Bridging rules
@ -1370,15 +1372,17 @@ class routerHBP(HBSYSTEM):
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
if _call_type == 'group':
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
## all_data(_data)
elif _call_type == 'unit':
if self._system not in UNIT:
logger.error('(%s) *UNIT CALL NOT FORWARDED* UNIT calling is disabled for this system (INGRESS)', self._system)
else:
self.unit_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
## all_data(_data)
elif _call_type == 'vcsbk':
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
logger.debug('CSBK recieved, forwarded to destination TG.')
all_data(_data)
## all_data(_data)
else:
logger.error('Unknown call type recieved -- not processed')

View File

@ -1196,9 +1196,32 @@ class OBP(OPENBRIDGE):
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
def svrd_received(self, _mode, _data):
print('SVRD RCV')
if _mode == b'UNIT':
UNIT_MAP[_data] = (self._system, time())
print(UNIT_MAP)
if _mode == b'DATA':
# DMR Data packet, sent via SVRD
_peer_id = _data[11:15]
_seq = _data[4]
_rf_src = _data[5:8]
_dst_id = _data[8:11]
_bits = _data[15]
_slot = 2 if (_bits & 0x80) else 1
#_call_type = 'unit' if (_bits & 0x40) else 'group'
if _bits & 0x40:
_call_type = 'unit'
elif (_bits & 0x23) == 0x23:
_call_type = 'vcsbk'
else:
_call_type = 'group'
_frame_type = (_bits & 0x30) >> 4
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
_stream_id = _data[16:20]
self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
pass
class HBP(HBSYSTEM):

View File

@ -187,6 +187,7 @@ class OPENBRIDGE(DatagramProtocol):
pass
def datagramReceived(self, _packet, _sockaddr):
## print(_packet[:4])
# Keep This Line Commented Unless HEAVILY Debugging!
## logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_packet))
if _packet[:4] == DMRD or _packet[:4] == EOBP:
@ -199,10 +200,6 @@ class OPENBRIDGE(DatagramProtocol):
_data = _packet[:53]
_hash = _packet[53:]
_ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest()
## print(ahex(_ckhs))
## print(ahex(_hash))
## print(compare_digest(_hash, _ckhs))
if compare_digest(_hash, _ckhs) and _sockaddr == self._config['TARGET_SOCK']:
_peer_id = _data[11:15]
@ -265,30 +262,33 @@ class OPENBRIDGE(DatagramProtocol):
elif _packet[:4] == SVRD:
_d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:])
## logger.info('SVRD Received: ' + str(_d_pkt))
# DMR Data packet, sent via SVRD
if _d_pkt[:4] == b'DATA':
_data = _d_pkt[4:]
_peer_id = _data[11:15]
_seq = _data[4]
_rf_src = _data[5:8]
_dst_id = _data[8:11]
_bits = _data[15]
_slot = 2 if (_bits & 0x80) else 1
#_call_type = 'unit' if (_bits & 0x40) else 'group'
if _bits & 0x40:
_call_type = 'unit'
elif (_bits & 0x23) == 0x23:
_call_type = 'vcsbk'
else:
_call_type = 'group'
_frame_type = (_bits & 0x30) >> 4
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
_stream_id = _data[16:20]
self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
else:
## if _d_pkt[4:8] == b'DATA':
## print('----------------------')
## _data = _d_pkt[4:]
## _peer_id = _data[11:15]
## _seq = _data[4]
## _rf_src = _data[5:8]
## _dst_id = _data[8:11]
## _bits = _data[15]
## _slot = 2 if (_bits & 0x80) else 1
## #_call_type = 'unit' if (_bits & 0x40) else 'group'
## if _bits & 0x40:
## _call_type = 'unit'
## elif (_bits & 0x23) == 0x23:
## _call_type = 'vcsbk'
## else:
## _call_type = 'group'
## _frame_type = (_bits & 0x30) >> 4
## _dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
## _stream_id = _data[16:20]
## print(_stream_id)
##
## print(_call_type)
## self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
## else:
self.svrd_received(_d_pkt[4:8], _d_pkt[8:])
self.svrd_received(_d_pkt[4:8], _d_pkt[8:])
#************************************************
# HB MASTER CLASS
@ -539,7 +539,6 @@ class HBSYSTEM(DatagramProtocol):
# Aliased in __init__ to datagramReceived if system is a master
def master_datagramReceived(self, _data, _sockaddr):
## global user_db
# Keep This Line Commented Unless HEAVILY Debugging!
# logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_data))