make channel opener more random

This commit is contained in:
DJ2LS 2023-11-02 15:02:47 +01:00
parent 5d7508dbed
commit 0c23ca0561
2 changed files with 7 additions and 4 deletions

View file

@ -2246,14 +2246,17 @@ class DATA:
)
# Let's check if we have a busy channel and if we are not in a running arq session.
if ModemParam.channel_busy and not ARQ.arq_state_event.is_set():
if ModemParam.channel_busy and not ARQ.arq_state_event.is_set() or ModemParam.is_codec2_traffic:
self.channel_busy_handler()
# if channel free, enqueue frame for tx
self.enqueue_frame_for_tx([connection_frame], c2_mode=FREEDV_MODE.sig0.value, copies=1, repeat_delay=0)
if not ARQ.arq_state_event.is_set():
self.enqueue_frame_for_tx([connection_frame], c2_mode=FREEDV_MODE.sig0.value, copies=1, repeat_delay=0)
# wait until timeout or event set
ARQ.arq_state_event.wait(timeout=self.datachannel_opening_interval)
random_wait_time = randrange(int(self.duration_sig1_frame * 10), int(self.datachannel_opening_interval * 10), 5)
ARQ.arq_state_event.wait(timeout=random_wait_time)
if ARQ.arq_state_event.is_set():
return True

View file

@ -137,7 +137,7 @@ class TCIParam:
@dataclass
class Modem:
version = "0.11.2-alpha.3"
version = "0.11.2-alpha.4"
host: str = "0.0.0.0"
port: int = 3000
SOCKET_TIMEOUT: int = 1 # seconds