diff --git a/hb_router.py b/hb_router.py index f524ef9..0dadda7 100755 --- a/hb_router.py +++ b/hb_router.py @@ -10,6 +10,7 @@ from __future__ import print_function # Python modules we need import sys +from binascii import b2a_hex as h # Debugging functions from pprint import pprint @@ -66,51 +67,49 @@ __status__ = 'pre-alpha' class routerMASTER(HBMASTER): - - def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): - _bits = int_id(_data[15]) + def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): + _bits = int_id(_data[15]) if _call_type == 'group': for rule in RULES[self._master]['GROUP_VOICE']: _target = rule['DST_NET'] if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True): - if RULE['SRC_TS'] != RULE['DST_TS']: + if rule['SRC_TS'] != rule['DST_TS']: _tmp_bits = _bits ^ 1 << 7 else: _tmp_bits = _bits - _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:] - print(h(_tmp_data)) + _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[11:15] + chr(_bits) + _data[16:] + print(h(_data)) print(h(_tmp_data)) systems[_target].send_system(_tmp_data) - logger.debug('(%s) Packet routed %s to system: %s', self._master, CONFIG[_target]['MODE'], _target) + logger.debug('(%s) Packet routed to %s system: %s', self._master, CONFIG['SYSTEMS'][_target]['MODE'], _target) else: - logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._master, _dst_id, _target) + logger.debug('(%s) Packet router no target TS/TGID %s/%s on target network %s', self._master, _slot, int_id(_dst_id), _target) continue class routerCLIENT(HBCLIENT): - def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): + def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): _bits = int_id(_data[15]) - if _call_type == 'group': for rule in RULES[self._client]['GROUP_VOICE']: _target = rule['DST_NET'] if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True): - if RULE['SRC_TS'] != RULE['DST_TS']: + if rule['SRC_TS'] != rule['DST_TS']: _tmp_bits = _bits ^ 1 << 7 else: _tmp_bits = _bits - _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:] - print(h(_tmp_data)) + _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[11:15] + chr(_bits) + _data[16:] + print(h(_data)) print(h(_tmp_data)) systems[_target].send_system(_tmp_data) - logger.debug('(%s) Packet routed to %s system: %s', self._client, CONFIG[_target]['MODE'], _target) + logger.debug('(%s) Packet routed to %s system: %s', self._client, CONFIG['SYSTEMS'][_target]['MODE'], _target) else: - logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._client, _dst_id, _target) + logger.debug('(%s) Packet router no target TS/TGID %s/%s on target network %s', self._master, _slot, int_id(_dst_id), _target) continue #************************************************ diff --git a/hblink.py b/hblink.py index cb3f9b0..6b11bb1 100755 --- a/hblink.py +++ b/hblink.py @@ -203,7 +203,7 @@ class HBMASTER(DatagramProtocol): # regardless of the system type (MASTER or CLIENT) send_system = send_clients - def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): + def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): pass def datagramReceived(self, _data, (_host, _port)): @@ -224,7 +224,7 @@ class HBMASTER(DatagramProtocol): _dst_id = _data[8:11] _bits = int_id(_data[15]) _slot = 2 if (_bits & 0x80) else 1 - _call_type = 'group' if (_bits & 0x40) else 'unit' + _call_type = 'unit' if (_bits & 0x40) else 'group' _raw_frame_type = (_bits & 0x30) >> 4 if _raw_frame_type == 0b00: _frame_type = 'voice' @@ -415,7 +415,7 @@ class HBCLIENT(DatagramProtocol): # regardless of the system type (MASTER or CLIENT) send_system = send_master - def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): + def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data): pass def datagramReceived(self, _data, (_host, _port)): @@ -434,7 +434,7 @@ class HBCLIENT(DatagramProtocol): _dst_id = _data[8:11] _bits = int_id(_data[15]) _slot = 2 if (_bits & 0x80) else 1 - _call_type = 'group' if (_bits & 0x40) else 'unit' + _call_type = 'unit' if (_bits & 0x40) else 'group' _raw_frame_type = (_bits & 0x30) >> 4 if _raw_frame_type == 0b00: _frame_type = 'voice'