Merge remote-tracking branch 'origin/consolidate-master-client' into consolidate-master-client
# Conflicts: # hb_router.py
This commit is contained in:
commit
a7af449c79
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@ Icon
|
|||||||
*.lcl
|
*.lcl
|
||||||
*.conf
|
*.conf
|
||||||
hblink.cfg
|
hblink.cfg
|
||||||
|
hb_routing_rules.py
|
||||||
*.config
|
*.config
|
||||||
*.json
|
*.json
|
||||||
*.pickle
|
*.pickle
|
||||||
|
78
hb_router.py
78
hb_router.py
@ -67,51 +67,51 @@ __status__ = 'pre-alpha'
|
|||||||
|
|
||||||
class routerMASTER(HBMASTER):
|
class routerMASTER(HBMASTER):
|
||||||
|
|
||||||
def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
|
def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
|
||||||
_bits = int_id(_data[15])
|
_bits = int_id(_data[15])
|
||||||
|
|
||||||
if _call_type == 'group':
|
if _call_type == 'group':
|
||||||
for rule in RULES[self._master]['GROUP_VOICE']:
|
for rule in RULES[self._master]['GROUP_VOICE']:
|
||||||
_target = rule['DST_NET']
|
_target = rule['DST_NET']
|
||||||
if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True):
|
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
|
_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))
|
|
||||||
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)
|
|
||||||
else:
|
else:
|
||||||
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._master, _dst_id, _target)
|
_tmp_bits = _bits
|
||||||
continue
|
_tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:]
|
||||||
|
print(h(_tmp_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)
|
||||||
|
else:
|
||||||
|
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._master, _dst_id, _target)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
class routerCLIENT(HBCLIENT):
|
class routerCLIENT(HBCLIENT):
|
||||||
|
|
||||||
def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
|
def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
|
||||||
_bits = int_id(_data[15])
|
_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']:
|
|
||||||
_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))
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
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']:
|
||||||
|
_tmp_bits = _bits ^ 1 << 7
|
||||||
else:
|
else:
|
||||||
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._client, _dst_id, _target)
|
_tmp_bits = _bits
|
||||||
continue
|
_tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:]
|
||||||
|
print(h(_tmp_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)
|
||||||
|
|
||||||
|
else:
|
||||||
|
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._client, _dst_id, _target)
|
||||||
|
continue
|
||||||
|
|
||||||
#************************************************
|
#************************************************
|
||||||
# MAIN PROGRAM LOOP STARTS HERE
|
# MAIN PROGRAM LOOP STARTS HERE
|
||||||
@ -124,9 +124,9 @@ if __name__ == '__main__':
|
|||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'MASTER':
|
if CONFIG['SYSTEMS'][system]['MODE'] == 'MASTER':
|
||||||
systems[system] = HBMASTER(system)
|
systems[system] = routerMASTER(system)
|
||||||
elif CONFIG['SYSTEMS'][system]['MODE'] == 'CLIENT':
|
elif CONFIG['SYSTEMS'][system]['MODE'] == 'CLIENT':
|
||||||
systems[system] = HBCLIENT(system)
|
systems[system] = routerCLIENT(system)
|
||||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||||
|
|
||||||
|
@ -235,7 +235,6 @@ class HBMASTER(DatagramProtocol):
|
|||||||
else:
|
else:
|
||||||
_frame_type = 'none'
|
_frame_type = 'none'
|
||||||
_stream_id = _data[16:20]
|
_stream_id = _data[16:20]
|
||||||
|
|
||||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._master, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._master, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
||||||
|
|
||||||
# If AMBE audio exporting is configured...
|
# If AMBE audio exporting is configured...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user