Use hi-res timer for loop control
This commit is contained in:
parent
501a557116
commit
cbd25b924d
@ -34,7 +34,7 @@ This program currently only works with group voice calls.
|
|||||||
# Python modules we need
|
# Python modules we need
|
||||||
import sys
|
import sys
|
||||||
from bitarray import bitarray
|
from bitarray import bitarray
|
||||||
from time import time,sleep
|
from time import time,sleep,perf_counter
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
@ -1362,7 +1362,7 @@ class routerOBP(OPENBRIDGE):
|
|||||||
'CONTENTION':False,
|
'CONTENTION':False,
|
||||||
'RFS': _rf_src,
|
'RFS': _rf_src,
|
||||||
'TGID': _dst_id,
|
'TGID': _dst_id,
|
||||||
'1ST': True,
|
'1ST': perf_counter(),
|
||||||
'lastSeq': False,
|
'lastSeq': False,
|
||||||
'lastData': False,
|
'lastData': False,
|
||||||
'RX_PEER': _peer_id
|
'RX_PEER': _peer_id
|
||||||
@ -1393,8 +1393,9 @@ class routerOBP(OPENBRIDGE):
|
|||||||
logger.warning("(%s) OBP *LoopControl* STREAM ID: %s ALREADY FINISHED FROM THIS SOURCE, IGNORING",self._system, int_id(_stream_id))
|
logger.warning("(%s) OBP *LoopControl* STREAM ID: %s ALREADY FINISHED FROM THIS SOURCE, IGNORING",self._system, int_id(_stream_id))
|
||||||
self.STATUS[_stream_id]['_finlog'] = True
|
self.STATUS[_stream_id]['_finlog'] = True
|
||||||
return
|
return
|
||||||
|
|
||||||
#LoopControl#
|
#LoopControl
|
||||||
|
hr_times = {}
|
||||||
for system in systems:
|
for system in systems:
|
||||||
if system == self._system:
|
if system == self._system:
|
||||||
continue
|
continue
|
||||||
@ -1409,16 +1410,25 @@ class routerOBP(OPENBRIDGE):
|
|||||||
else:
|
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 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 _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[_stream_id] or not self.STATUS[_stream_id]['LOOPLOG']:
|
hr_times[system] = systems[system].STATUS[_stream_id]['1ST']
|
||||||
logger.warning("(%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))
|
|
||||||
self.STATUS[_stream_id]['LOOPLOG'] = True
|
#use the minimum perf_counter to ensure
|
||||||
self.STATUS[_stream_id]['LAST'] = pkt_time
|
#We always use only the earliest packet
|
||||||
|
fi = min(hr_times, key=hr_times.get)
|
||||||
if CONFIG['SYSTEMS'][self._system]['ENHANCED_OBP'] and '_bcsq' not in self.STATUS[_stream_id]:
|
|
||||||
systems[self._system].send_bcsq(_dst_id,_stream_id)
|
hr_times = None
|
||||||
#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
|
if self._system != fi:
|
||||||
return
|
if 'LOOPLOG' not in self.STATUS[_stream_id] or not self.STATUS[_stream_id]['LOOPLOG']:
|
||||||
|
logger.warning("(%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))
|
||||||
|
self.STATUS[_stream_id]['LOOPLOG'] = True
|
||||||
|
self.STATUS[_stream_id]['LAST'] = pkt_time
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
#Duplicate handling#
|
#Duplicate handling#
|
||||||
#Duplicate complete packet
|
#Duplicate complete packet
|
||||||
|
@ -316,6 +316,7 @@ def build_config(_config_file):
|
|||||||
'MODE': config.get(section, 'MODE'),
|
'MODE': config.get(section, 'MODE'),
|
||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
'NETWORK_ID': config.getint(section, 'NETWORK_ID').to_bytes(4, 'big'),
|
'NETWORK_ID': config.getint(section, 'NETWORK_ID').to_bytes(4, 'big'),
|
||||||
|
'OVERRIDE_SERVER_ID': config.getint(section, 'OVERRIDE_SERVER_ID').to_bytes(4, 'big'),
|
||||||
'IP': config.get(section, 'IP'),
|
'IP': config.get(section, 'IP'),
|
||||||
'PORT': config.getint(section, 'PORT'),
|
'PORT': config.getint(section, 'PORT'),
|
||||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE').ljust(20,'\x00')[:20], 'utf-8'),
|
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE').ljust(20,'\x00')[:20], 'utf-8'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user