Filter announcements by TG: only send to peers active on matching talkgroup

pull/26/head
Joaquin Madrid Belando 3 weeks ago
parent 0d466a3291
commit 5123dd3d1a

@ -978,6 +978,24 @@ def _saveRecording():
_recording_state['frames'] = 0 _recording_state['frames'] = 0
_recording_state['rf_src'] = None _recording_state['rf_src'] = None
def _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx):
_tg_bytes = bytes_3(_tg) if isinstance(_tg, int) else _tg
if hasattr(_sys_obj, '_peer_tg') and hasattr(_sys_obj, '_peers'):
_sent_count = 0
for _peer in list(_sys_obj._peers.keys()):
_send = False
if _peer in _sys_obj._peer_tg:
if _ts in _sys_obj._peer_tg[_peer]:
if _sys_obj._peer_tg[_peer][_ts]['tgid'] == _tg_bytes:
_send = True
if _send:
_sys_obj.send_peer(_peer, pkt)
_sent_count += 1
return _sent_count
else:
_sys_obj.send_system(pkt)
return -1
def _announcementSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _tg, _ts, _ann_num=1, _next_time=None): def _announcementSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _tg, _ts, _ann_num=1, _next_time=None):
global _announcement_running global _announcement_running
@ -1015,7 +1033,9 @@ def _announcementSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _
else: else:
_sys_obj.STATUS[_stream_id]['LAST'] = _now _sys_obj.STATUS[_stream_id]['LAST'] = _now
_slot['TX_TIME'] = _now _slot['TX_TIME'] = _now
_sys_obj.send_system(pkt) _fc = _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx)
if _pkt_idx == 0 and _fc >= 0:
logger.info('(%s) TG filter: %s/%s peers match TG %s TS%s on %s', _label, _fc, len(_sys_obj._peers), _tg, _ts, _t['name'])
except Exception as e: except Exception as e:
logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e) logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e)
@ -1350,7 +1370,9 @@ def _ttsSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _tg, _ts,
else: else:
_sys_obj.STATUS[_stream_id]['LAST'] = _now _sys_obj.STATUS[_stream_id]['LAST'] = _now
_slot['TX_TIME'] = _now _slot['TX_TIME'] = _now
_sys_obj.send_system(pkt) _fc = _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx)
if _pkt_idx == 0 and _fc >= 0:
logger.info('(%s) TG filter: %s/%s peers match TG %s TS%s on %s', _label, _fc, len(_sys_obj._peers), _tg, _ts, _t['name'])
except Exception as e: except Exception as e:
logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e) logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e)
@ -2300,6 +2322,7 @@ class routerHBP(HBSYSTEM):
} }
} }
self.CALL_DATA = [] self.CALL_DATA = []
self._peer_tg = {}
def to_target(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, pkt_time, dmrpkt, _bits,_bridge,_system,_noOBP,sysIgnore,_source_server, _ber, _rssi, _source_rptr): def to_target(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, pkt_time, dmrpkt, _bits,_bridge,_system,_noOBP,sysIgnore,_source_server, _ber, _rssi, _source_rptr):
_sysIgnore = sysIgnore _sysIgnore = sysIgnore
@ -2998,6 +3021,11 @@ class routerHBP(HBSYSTEM):
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) 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)
if CONFIG['REPORTS']['REPORT']: if CONFIG['REPORTS']['REPORT']:
self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore'))
if _peer_id not in self._peer_tg:
self._peer_tg[_peer_id] = {}
self._peer_tg[_peer_id][_slot] = {'tgid': _dst_id, 'time': pkt_time}
else: else:
logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %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, _dtype_vseq) 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, _dtype_vseq)

Loading…
Cancel
Save

Powered by TurnKey Linux.