From 60d99523f37ea0e9a2073722ba9873cb98a1440e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 10 Nov 2021 01:58:20 +0000 Subject: [PATCH 1/7] Squashed commit of the following: commit 650ac29dc40ea8ada5e1ea8c655c916c8d5f8807 Author: Simon Date: Wed Nov 10 00:42:48 2021 +0000 Allow both slots for PC to a peer-connected D-APRS server commit 6ba9c40c58b6c8b451f577a26016a8f8fd0ba667 Author: Simon Date: Wed Nov 10 00:38:45 2021 +0000 bits commit 34a8aaf1d21d584d38aaf168e38c1f69bdc031ff Author: Simon Date: Wed Nov 10 00:14:14 2021 +0000 slot2 commit 01aa95e65b76711041560b8d0896d0eee2093f03 Author: Simon Date: Tue Nov 9 23:49:28 2021 +0000 debug 900999 commit 067e598ae02304708b56bc62279a99d0fd3c32a5 Author: Simon Date: Tue Nov 9 23:38:04 2021 +0000 indent commit 716935cb4c478674b4de5f5e6783c74675055fc2 Author: Simon Date: Tue Nov 9 23:37:04 2021 +0000 route D-APRS ID 900999 via master connection if D-APRS system exists commit ab0fc7c1083792731de3f76eaf357db3c0e2b5a1 Author: Simon Date: Tue Nov 9 23:02:32 2021 +0000 perform slot rewrites on unit data calls commit d5c4315dcb104baaf8586d8ff5d979f974ea30d4 Author: Simon Date: Tue Nov 9 22:37:20 2021 +0000 we need to recognise slot1 PC too commit 67e397c523d22c9da20d80d1ff13c4f021c4a43a Author: Simon Date: Tue Nov 9 12:37:55 2021 +0000 output bit pattern commit 03b2316771ea015811537a0a7e05e28b7da605cd Author: Simon Date: Tue Nov 9 00:36:20 2021 +0000 remove txtime updating for data calls commit 0de4a503cb87e507cd0f5f680da5915ad0b587fa Author: Simon Date: Mon Nov 8 23:11:13 2021 +0000 remove txtime updating for data calls commit db802ce3a12b52fd4d6d7f851f10ee68e236f792 Author: Simon Date: Mon Nov 8 23:03:53 2021 +0000 more testing stuffyta commit 339ad578a343f28477bc405eebd68102261acc95 Author: Simon Date: Mon Nov 8 22:50:27 2021 +0000 more testing stuffyt commit c8b0e5bceb545c29f07c73578b8f60844eba0f9c Author: Simon Date: Mon Nov 8 22:49:34 2021 +0000 more testing stuffy commit 3559a16fd1375fc5654aed1cf0c38b1796a3b096 Author: Simon Date: Mon Nov 8 22:48:46 2021 +0000 more testing stuff commit 766485a50a833d1e281e52daf22ab2199d73ce2c Author: Simon Date: Mon Nov 8 22:34:52 2021 +0000 s 2 commit 4060bd394611bc6a399fb22d40aaa4d7f1f728bc Author: Simon Date: Mon Nov 8 22:32:08 2021 +0000 d_system again commit f3fc33f538f0f79764f9e1c017b45d723b58e3ed Author: Simon Date: Mon Nov 8 22:30:43 2021 +0000 fixy fixy commit 741cd87834a0e014a4a1de80f71b9a09025a46a2 Author: Simon Date: Mon Nov 8 22:19:50 2021 +0000 kk commit f3b44af9d99a1fba607c7529f27030434d21c76d Author: Simon Date: Mon Nov 8 19:40:47 2021 +0000 kk commit 48fffecd26442c3f032562797eccbd219ac2262c Author: Simon Date: Mon Nov 8 19:15:52 2021 +0000 typo commit 21486b55c772ddfebe5b4c18dd86923552781453 Author: Simon Date: Mon Nov 8 19:15:14 2021 +0000 dd commit 024af2d45842366e6d37b97a817922d6bcbc4326 Author: Simon Date: Mon Nov 8 19:12:18 2021 +0000 d commit 2f1df72994e7f376dc15b6d6089825219c0ec6c2 Author: Simon Date: Mon Nov 8 19:02:34 2021 +0000 add more debug, slice ID as string commit 7a0744e8395cd1487b341e0000052f47e701ef2b Author: Simon Date: Mon Nov 8 18:57:39 2021 +0000 fix bug in hs, log sub_map fo test commit 9738020e2198c7955bb5d498cd68f03f7c4e1145 Author: Simon Date: Mon Nov 8 18:21:24 2021 +0000 test ID in SUB_MAP commit 10d1c06303e2c0da192fbf17b19f08a89c0c3df6 Author: Simon Date: Mon Nov 8 17:53:33 2021 +0000 only try hotspot ID when SUB_MAP not matched. Some fixes in logging commit cad82c4cfe4c18961f4dc5efa77c5c93d68285be Author: Simon Date: Mon Nov 8 01:34:50 2021 +0000 lvkbl commit 8c24f39a5eb4c82822b7a467b80b2ec7ee7a6e73 Author: Simon Date: Mon Nov 8 01:32:48 2021 +0000 system commit f9e7416f6d6fa2f4269620eb0437587845a9c2f5 Author: Simon Date: Mon Nov 8 01:28:16 2021 +0000 Send data to system if logged in with destination ID commit 44d93c7691c8845b75544a4e5bb78afcbaa434ed Author: Simon Date: Sun Nov 7 23:08:30 2021 +0000 remiove commit eb7e091796286fc4c673317b0437e39add35a203 Author: Simon Date: Sun Nov 7 20:20:35 2021 +0000 sub map trimmer loop - correction commit a27f5172ab7af56ab43090847c5f70ca306ad1b4 Author: Simon Date: Sun Nov 7 20:18:40 2021 +0000 sub map trimmer loop commit f32f372bbbf1342dab69b9053d4a92f46a0bcf5d Author: Simon Date: Sun Nov 7 17:48:13 2021 +0000 indent commit e5d510b55ee403619c396cb9856790a279b18bc7 Author: Simon Date: Sun Nov 7 17:47:33 2021 +0000 typo commit d283aa7b6b6478095ee8ef8e854b115ac3ce6cd9 Author: Simon Date: Sun Nov 7 17:46:58 2021 +0000 typo commit 48b7c0e05de736fc6ee9d0d26567f431844764f9 Author: Simon Date: Sun Nov 7 17:45:13 2021 +0000 more logging corrections commit 6fb9f57f9567a65255b9dcb5bf89cf255324617c Author: Simon Date: Sun Nov 7 14:30:02 2021 +0000 remove slot rewrite commit 3ed13d56a3be01f4a598a5ca1653f9f553cf486b Author: Simon Date: Sun Nov 7 14:25:45 2021 +0000 _d_system commit d4979fa40ecf75e504617bf890cddd14cee83fe9 Author: Simon Date: Sun Nov 7 14:24:09 2021 +0000 d_system commit 56de60dd07e27b78e3c0e5f158d4591654963102 Author: Simon Date: Sun Nov 7 14:22:00 2021 +0000 duh commit ef9e68b1e8b547f1bf40a23a60655a619eca3a34 Author: Simon Date: Sun Nov 7 14:01:44 2021 +0000 duh commit a11e2842492b73a29faa7dff4047fff3e97773c8 Author: Simon Date: Sun Nov 7 14:00:01 2021 +0000 log SUB_MAP commit b855b204e66b2318484ed26b27b1dae581d6d6aa Author: Simon Date: Sun Nov 7 13:35:30 2021 +0000 more logging... commit 5cd474dff71af77caac1a80a2b2691eca043a5c3 Author: Simon Date: Sun Nov 7 13:33:14 2021 +0000 more logging commit baea91905f586829bf0297eaa539395da272d487 Author: Simon Date: Sun Nov 7 13:23:34 2021 +0000 boing commit 738286c495c14ae5869aadaf5c8ded28ce69bcf5 Author: Simon Date: Sun Nov 7 12:35:56 2021 +0000 add login for SUB_MAP hits commit 41228f45894b93d4260721168bab8aa6d6b139d6 Author: Simon Date: Sat Nov 6 21:33:34 2021 +0000 d_system commit cd4b0444c68cd7605e07e0fb174b9d0863dd3673 Author: Simon Date: Sat Nov 6 21:29:50 2021 +0000 rf src commit a186cd233caf93796231f074d25997958c33383c Author: Simon Date: Sat Nov 6 21:27:33 2021 +0000 dst_id commit 1684d7d7c3e8775277fb14f8d0b1b1009abb45ae Author: Simon Date: Sat Nov 6 21:25:47 2021 +0000 use correct ID for SUB_MAP commit 0102d9dad5079beff1b23ef5b00eb86558a0fbc6 Author: Simon Date: Sat Nov 6 21:20:48 2021 +0000 Add first support for SUB_MAP and sending data calls to HBP. commit 4e81176a926efc93c91a22786d659fc69fc48542 Author: Simon Date: Sat Nov 6 13:49:51 2021 +0000 Start work on unit data to other HBP systems commit d6b67128897d7a708646304444101b62e08bce8c Author: Simon Date: Sat Nov 6 13:26:24 2021 +0000 Tidy up and remove some commented lines --- bridge_master.py | 169 ++++++++++++++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 60 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 8e07bfe..4c8db6b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -377,6 +377,19 @@ def kaReporting(): logger.warning('(ROUTER) not sending to system %s as KeepAlive never seen',system) elif CONFIG['SYSTEMS'][system]['_bcka'] < time() - 60: logger.warning('(ROUTER) not sending to system %s as last KeepAlive was %s seconds ago',system, int(time() - CONFIG['SYSTEMS'][system]['_bcka'])) + +#Subscriber Map trimmer loop +def SubMapTrimmer(): + logger.debug('(SUBSCRIBER) Subscriber Map trimmer loop started') + _sub_time = time() + _remove_list = [] + for _subscriber in SUB_MAP: + if _subscriber[2] < (_sub_time - 86400): + _remove_list.append(_subscriber) + + for _remove in _remove_list: + SUB_MAP.pop(_remove) + # run this every 10 seconds to trim stream ids def stream_trimmer_loop(): @@ -1518,7 +1531,6 @@ class routerOBP(OPENBRIDGE): if CONFIG['SYSTEMS'][self._system]['ENHANCED_OBP'] and '_bcsq' not in self.STATUS[_stream_id]: systems[self._system].send_bcsq(_dst_id,_stream_id) - #logger.warning("(%s) OBP *BridgeControl* Sent BCSQ , STREAM ID: %s, TG %s",self._system, int_id(_stream_id), int_id(_dst_id)) self.STATUS[_stream_id]['_bcsq'] = True return @@ -1557,8 +1569,6 @@ class routerOBP(OPENBRIDGE): _sysIgnore = [] for _bridge in BRIDGES: - #if _bridge[0:1] != '#': - #if True: for _system in BRIDGES[_bridge]: if _system['SYSTEM'] == self._system and _system['TGID'] == _dst_id and _system['TS'] == _slot and _system['ACTIVE'] == True: @@ -1573,12 +1583,7 @@ class routerOBP(OPENBRIDGE): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('GROUP VOICE,END,RX,{},{},{},{},{},{},{:.2f}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id), call_duration).encode(encoding='utf-8', errors='ignore')) self.STATUS[_stream_id]['_fin'] = True - #removed = self.STATUS.pop(_stream_id) - #logger.debug('(%s) OpenBridge sourced call stream end, remove terminated Stream ID: %s', self._system, int_id(_stream_id)) - #if not removed: - #selflogger.error('(%s) *CALL END* STREAM ID: %s NOT IN LIST -- THIS IS A REAL PROBLEM', self._system, int_id(_stream_id)) - - #Reset sequence number + self.STATUS[_stream_id]['lastSeq'] = False class routerHBP(HBSYSTEM): @@ -1667,7 +1672,6 @@ class routerHBP(HBSYSTEM): #If target has quenched us, don't send if ('_bcsq' in _target_system) and (_dst_id in _target_system['_bcsq']) and (_target_system['_bcsq'][_target['TGID']] == _stream_id): - #logger.info('(%s) Conference Bridge: %s, is Source Quenched for Stream ID: %s, skipping system: %s TS: %s, TGID: %s', self._system, _bridge, int_id(_stream_id), _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) continue #If target has missed 6 (on 1 min) of keepalives, don't send @@ -1677,12 +1681,10 @@ class routerHBP(HBSYSTEM): #If talkgroup is prohibited by ACL if self._CONFIG['GLOBAL']['USE_ACL']: if not acl_check(_target['TGID'],self._CONFIG['GLOBAL']['TG1_ACL']): - #logger.info('(%s) TGID prohibited by ACL, not sending', _target['SYSTEM']) continue if _target_system['USE_ACL']: if not acl_check(_target['TGID'],_target_system['TG1_ACL']): - #logger.info('(%s) TGID prohibited by ACL, not sending', _target['SYSTEM']) continue @@ -1818,7 +1820,7 @@ class routerHBP(HBSYSTEM): # Transmit the packet to the destination system systems[_target['SYSTEM']].send_system(_tmp_data) - #logger.debug('(%s) Packet routed by bridge: %s to system: %s TS: %s, TGID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) + return _sysIgnore def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): @@ -1835,28 +1837,13 @@ class routerHBP(HBSYSTEM): # Assume this is not a data call. We use this to prevent SMS/GPS data from triggering a reflector. _data_call = False _voice_call = False -## print(self._system) -## print(UNIT_MAP) - # Make/update an entry in the UNIT_MAP for this subscriber - #UNIT_MAP[_rf_src] = (self._system, pkt_time) - -## print() -## print(_call_type) -## print(_dtype_vseq) -## print(_frame_type) -## print(_stream_id) -## print(_seq) -## print(ahex(dmrpkt)) -## if _dtype_vseq == 3: -## print(ahex(dmrpkt)[27:-27]) -## print() - # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - #logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,int_id(_stream_id)) - ## + + #Add system to SUB_MAP + SUB_MAP[_rf_src] = (self._system,_slot,pkt_time) + if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): -## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': - # This is a data call _data_call = True + if _dtype_vseq == 3: logger.info('(%s) *UNIT CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) @@ -1921,19 +1908,93 @@ class routerHBP(HBSYSTEM): logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not valid. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) elif CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] != 'OPENBRIDGE': logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not OPENBRIDGE. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) - - - + + #If destination ID is in the Subscriber Map + if _dst_id in SUB_MAP: + (_d_system,_d_slot,_d_time) = SUB_MAP[_dst_id] + _dst_slot = systems[_d_system].STATUS[_d_slot] + logger.info('(%s) SUB_MAP matched, System: %s Slot: %s, Time: %s',self._system, _d_system,_d_slot,_d_time) + #If slot is idle for RX and TX + if (_dst_slot['RX_TYPE'] == HBPF_SLT_VTERM) and (_dst_slot['TX_TYPE'] == HBPF_SLT_VTERM) and (time() - _dst_slot['TX_TIME'] > CONFIG['SYSTEMS'][_d_system]['GROUP_HANGTIME']): + #rewrite slot if required + if _slot != _d_slot: + _tmp_bits = _bits ^ 1 << 7 + else: + _tmp_bits = _bits + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[_d_system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + + #_dst_slot['TX_TIME'] = pkt_time + else: + logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + + elif _int_dst_id == 900999: + if 'D-APRS' in systems and CONFIG['SYSTEMS']['D-APRS']['MODE'] == 'MASTER': + _d_system = 'D-APRS' + _dst_slot = systems['D-APRS'].STATUS[2] + logger.info('(%s) D-APRS ID matched, System: %s Slot: 2',self._system, _d_system) + #If slot is idle for RX and TX + if (_dst_slot['RX_TYPE'] == HBPF_SLT_VTERM) and (_dst_slot['TX_TYPE'] == HBPF_SLT_VTERM) and (time() - _dst_slot['TX_TIME'] > CONFIG['SYSTEMS'][_d_system]['GROUP_HANGTIME']): + #We will allow the system to use both slots + _tmp_bits = _bits + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[_d_system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + + #_dst_slot['TX_TIME'] = pkt_time + else: + logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + + else: + #If destination ID is logged in as a hotspot + for _d_system in systems: + if CONFIG['SYSTEMS'][_d_system]['MODE'] == 'MASTER': + for _to_peer in CONFIG['SYSTEMS'][_d_system]['PEERS']: + _int_to_peer = int_id(_to_peer) + if (str(_int_to_peer)[:7] == str(_int_dst_id)[:7]): + #(_d_system,_d_slot,_d_time) = SUB_MAP[_dst_id] + _d_slot = _slot + _dst_slot = systems[_d_system].STATUS[_d_slot] + logger.info('(%s) User Peer Hotspot ID matched, System: %s Slot: %s',self._system, _d_system,_d_slot) + #If slot is idle for RX and TX + if (_dst_slot['RX_TYPE'] == HBPF_SLT_VTERM) and (_dst_slot['TX_TYPE'] == HBPF_SLT_VTERM) and (time() - _dst_slot['TX_TIME'] > CONFIG['SYSTEMS'][_d_system]['GROUP_HANGTIME']): + #Always use slot2 for hotspots - many of them are simplex and this + #is the convention + #rewrite slot if required (slot 2 is used on hotspots) + if _slot != 2: + _tmp_bits = _bits ^ 1 << 7 + else: + _tmp_bits = _bits + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[_d_system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + + #_dst_slot['TX_TIME'] = pkt_time + else: + logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + - #Handle private calls (for reflectors) - if _call_type == 'unit' and _slot == 2 and not _data_call: + #Handle private voice calls (for reflectors) + if _call_type == 'unit' and not _data_call: if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['_stopTgAnnounce'] = False logger.warning('(%s) Reflector: Private call from %s to %s',self._system, int_id(_rf_src), _int_dst_id) - #if _int_dst_id >= 4000 and _int_dst_id <= 5000: if _int_dst_id >= 5 and _int_dst_id != 9 and _int_dst_id <= 999999: _bridgename = '#'+ str(_int_dst_id) if _bridgename not in BRIDGES and not (_int_dst_id >= 4000 and _int_dst_id <= 5000) and not (_int_dst_id >=9991 and _int_dst_id <= 9999): @@ -1974,7 +2035,6 @@ class routerHBP(HBSYSTEM): # Set the matching rule as ACTIVE #Single TG mode if _dst_id in _system['OFF'] or _int_dst_id != int(_dehash_bridge) : - #if _dst_id in _system['OFF']: if _system['ACTIVE'] == True: _system['ACTIVE'] = False logger.info('(%s) [F] Reflector: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE']) @@ -1994,14 +2054,8 @@ class routerHBP(HBSYSTEM): if (_frame_type == HBPF_DATA_SYNC) and (_dtype_vseq == HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != HBPF_SLT_VTERM): - #Speak callsign before message _say = [words[_lang]['silence']] - # _systemcs = re.sub(r'\W+', '', self._system) - # _systemcs.upper() - # for character in _systemcs: - # _say.append(words[character]) - # _say.append(words['silence']) - + if _int_dst_id <= 5 or _int_dst_id == 9: logger.info('(%s) Reflector: voice called - TG < 5 or 9 - "busy""', self._system) _say.append(words[_lang]['busy']) @@ -2149,7 +2203,6 @@ class routerHBP(HBSYSTEM): self.STATUS[_slot]['LAST'] = pkt_time return else: - #if _stream_id in systems[system].STATUS and systems[system].STATUS[_stream_id]['START'] <= self.STATUS[_stream_id]['START']: if _stream_id in systems[system].STATUS and '1ST' in systems[system].STATUS[_stream_id] and systems[system].STATUS[_stream_id]['TGID'] == _dst_id: if 'LOOPLOG' not in self.STATUS[_slot] or not self.STATUS[_slot]['LOOPLOG']: logger.info("(%s) OBP *LoopControl* FIRST OBP %s, STREAM ID: %s, TG %s, IGNORE THIS SOURCE",self._system, system, int_id(_stream_id), int_id(_dst_id)) @@ -2158,7 +2211,6 @@ class routerHBP(HBSYSTEM): if CONFIG['SYSTEMS'][self._system]['ENHANCED_OBP'] and '_bcsq' not in self.STATUS[_slot]: systems[self._system].send_bcsq(_dst_id,_stream_id) - #logger.warning("(%s) OBP *BridgeControl* Sent BCSQ , STREAM ID: %s, TG %s",self._system, int_id(_stream_id), int_id(_dst_id)) self.STATUS[_slot]['_bcsq'] = True return @@ -2272,10 +2324,8 @@ class routerHBP(HBSYSTEM): else: if (_dst_id in _system['OFF'] or _dst_id in _system['RESET']) and _slot == _system['TS']: - #if (_dst_id in _system['OFF'] or _dst_id in _system['RESET']) and _slot == _system['TS']: # Set the matching rule as ACTIVE if _dst_id in _system['OFF']: - #if _dst_id in _system['OFF']: if _system['ACTIVE'] == True: _system['ACTIVE'] = False logger.info('(%s) [9] Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE']) @@ -2422,6 +2472,9 @@ if __name__ == '__main__': # Build the routing rules file BRIDGES = make_bridges(rules_module.BRIDGES) + #Subscriber map for unit calls - complete with test entry + SUB_MAP = {bytes_3(73578):('REP-1',1,time())} + #Generator generator = {} systemdelete = [] @@ -2466,12 +2519,6 @@ if __name__ == '__main__': if CONFIG['SYSTEMS'][system]['TS2_STATIC']: ts2 = CONFIG['SYSTEMS'][system]['TS2_STATIC'].split(',') - #if CONFIG['SYSTEMS'][system]['SINGLE_MODE'] == True: - #if ts1: - #make_static_tg(int(ts1[0]),1,system) - #if ts2: - #make_static_tg(int(ts2[0]),2,system) - #else: for tg in ts1: if not tg: continue @@ -2516,9 +2563,6 @@ if __name__ == '__main__': for system in CONFIG['SYSTEMS']: if CONFIG['SYSTEMS'][system]['ENABLED']: - # if CONFIG['SYSTEMS'][system]['MODE'] == 'XLXPEER': - # logger.warning('(GLOBAL) system %s not started - XLXPEER connections currently unsupported ', system) - # continue if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': systems[system] = routerOBP(system, CONFIG, report_server) else: @@ -2572,6 +2616,11 @@ if __name__ == '__main__': ka = ka_task.start(60) ka.addErrback(loopingErrHandle) + #Subscriber map trimmer + sub_trimmer_task = task.LoopingCall(SubMapTrimmer) + sub_trimmer = sub_trimmer_task.start(3600)#3600 + sub_trimmer.addErrback(loopingErrHandle) + #more threads reactor.suggestThreadPoolSize(100) From f4deee69b7551a6adad61119bccce68b3501264b Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 12:55:15 +0000 Subject: [PATCH 2/7] move HBP data sending to function --- bridge_master.py | 53 +++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 4c8db6b..b8c38d8 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1822,6 +1822,15 @@ class routerHBP(HBSYSTEM): systems[_target['SYSTEM']].send_system(_tmp_data) return _sysIgnore + + def sendDataToHBP(self,d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src): + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[_d_system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pkt_time = time() @@ -1922,12 +1931,13 @@ class routerHBP(HBSYSTEM): else: _tmp_bits = _bits #Assemble transmit HBP packet header - _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[_d_system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) - if CONFIG['REPORTS']['REPORT']: - systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + #_tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + #_tmp_data = b''.join([_tmp_data, dmrpkt]) + #systems[_d_system].send_system(_tmp_data) + #logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + #if CONFIG['REPORTS']['REPORT']: + #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1936,19 +1946,20 @@ class routerHBP(HBSYSTEM): elif _int_dst_id == 900999: if 'D-APRS' in systems and CONFIG['SYSTEMS']['D-APRS']['MODE'] == 'MASTER': _d_system = 'D-APRS' - _dst_slot = systems['D-APRS'].STATUS[2] - logger.info('(%s) D-APRS ID matched, System: %s Slot: 2',self._system, _d_system) + _dst_slot = systems['D-APRS'].STATUS[_slot] + logger.info('(%s) D-APRS ID matched, System: %s Slot: %s',self._system, _d_system,_slot) #If slot is idle for RX and TX if (_dst_slot['RX_TYPE'] == HBPF_SLT_VTERM) and (_dst_slot['TX_TYPE'] == HBPF_SLT_VTERM) and (time() - _dst_slot['TX_TIME'] > CONFIG['SYSTEMS'][_d_system]['GROUP_HANGTIME']): #We will allow the system to use both slots _tmp_bits = _bits #Assemble transmit HBP packet header - _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[_d_system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) - if CONFIG['REPORTS']['REPORT']: - systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + #_tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + #_tmp_data = b''.join([_tmp_data, dmrpkt]) + #systems[_d_system].send_system(_tmp_data) + #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + #if CONFIG['REPORTS']['REPORT']: + #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1975,13 +1986,13 @@ class routerHBP(HBSYSTEM): else: _tmp_bits = _bits #Assemble transmit HBP packet header - _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[_d_system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) - if CONFIG['REPORTS']['REPORT']: - systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - + #_tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + #_tmp_data = b''.join([_tmp_data, dmrpkt]) + #systems[_d_system].send_system(_tmp_data) + #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) + #if CONFIG['REPORTS']['REPORT']: + #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) From 5902d5a46e74c1c5348da3bbac02f1989d8ff8f2 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 13:51:50 +0000 Subject: [PATCH 3/7] _d_system --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index b8c38d8..2b0c886 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1937,7 +1937,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1959,7 +1959,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1992,7 +1992,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) From 6d7567f10ac36be7eb919a052fc9239d9b6bbcf4 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 13:58:00 +0000 Subject: [PATCH 4/7] it's all about underscores --- bridge_master.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 2b0c886..2f7627b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1823,7 +1823,7 @@ class routerHBP(HBSYSTEM): return _sysIgnore - def sendDataToHBP(self,d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src): + def sendDataToHBP(self,_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src): #Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt]) @@ -1937,7 +1937,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1959,7 +1959,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1992,7 +1992,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system, d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) From bdb0738f7ab7df614fb26acde91ebbc27350c4b6 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 14:01:55 +0000 Subject: [PATCH 5/7] d_slot --- bridge_master.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bridge_master.py b/bridge_master.py index 2f7627b..65af5c5 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1946,6 +1946,7 @@ class routerHBP(HBSYSTEM): elif _int_dst_id == 900999: if 'D-APRS' in systems and CONFIG['SYSTEMS']['D-APRS']['MODE'] == 'MASTER': _d_system = 'D-APRS' + _d_slot = _slot _dst_slot = systems['D-APRS'].STATUS[_slot] logger.info('(%s) D-APRS ID matched, System: %s Slot: %s',self._system, _d_system,_slot) #If slot is idle for RX and TX From 64f7e813d1860324480cf6672115e778ed2b7ef1 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 14:03:41 +0000 Subject: [PATCH 6/7] dmrpkt --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 65af5c5..6aa9370 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1937,7 +1937,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot 1: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1960,7 +1960,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: @@ -1993,7 +1993,7 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to HBP on slot: %s DST_ID: %s',self._system,_d_system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[_d_system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_d_system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src) + self.sendDataToHBP(_d_system,_d_slot,_dst_id,_tmp_bits,_data,dmrpkt,_rf_src) #_dst_slot['TX_TIME'] = pkt_time else: logger.info('(%s) UNIT Data not bridged to HBP on slot 1 - target busy: %s DST_ID: %s',self._system,_d_system,_int_dst_id) From 5a3de367fc5bbb11905f97cc37d1d5d85311028d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Nov 2021 14:05:08 +0000 Subject: [PATCH 7/7] dmrpkt --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 6aa9370..ad415c5 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1823,7 +1823,7 @@ class routerHBP(HBSYSTEM): return _sysIgnore - def sendDataToHBP(self,_d_system,_d_slot,_dst_id,_tmp_bits,_data,_dmrpkt,_rf_src): + def sendDataToHBP(self,_d_system,_d_slot,_dst_id,_tmp_bits,_data,dmrpkt,_rf_src): #Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt])