mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
use busy detection while opening a channel
This commit is contained in:
parent
9dad094e47
commit
d572772df3
|
@ -1840,36 +1840,7 @@ class DATA:
|
|||
# for calculating transmission statistics
|
||||
# static.ARQ_COMPRESSION_FACTOR = len(data_out) / len(lzma.compress(data_out))
|
||||
|
||||
# Let's check if we have a busy channel and if we are not in a running arq session.
|
||||
if static.CHANNEL_BUSY and not static.ARQ_SESSION:
|
||||
self.log.warning("[TNC] Channel busy, waiting until free...")
|
||||
self.send_data_to_socket_queue(
|
||||
freedata="tnc-message",
|
||||
arq="transmission",
|
||||
status="waiting",
|
||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||
)
|
||||
|
||||
# wait while timeout not reached and our busy state is busy
|
||||
channel_busy_timeout = time.time() + 30
|
||||
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
||||
threading.Event().wait(0.01)
|
||||
|
||||
# if channel busy timeout reached, stop connecting
|
||||
if time.time() > channel_busy_timeout:
|
||||
self.log.warning("[TNC] Channel busy, try again later...")
|
||||
static.ARQ_SESSION_STATE = "failed"
|
||||
self.send_data_to_socket_queue(
|
||||
freedata="tnc-message",
|
||||
arq="transmission",
|
||||
status="failed",
|
||||
reason="busy",
|
||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||
)
|
||||
static.ARQ_SESSION_STATE = "disconnected"
|
||||
return False
|
||||
|
||||
self.arq_open_data_channel(mode, n_frames_per_burst, mycallsign)
|
||||
|
||||
|
@ -1945,6 +1916,37 @@ class DATA:
|
|||
attempt=f"{str(attempt + 1)}/{str(self.data_channel_max_retries)}",
|
||||
)
|
||||
|
||||
# Let's check if we have a busy channel and if we are not in a running arq session.
|
||||
if static.CHANNEL_BUSY and not static.ARQ_STATE:
|
||||
self.log.warning("[TNC] Channel busy, waiting until free...")
|
||||
self.send_data_to_socket_queue(
|
||||
freedata="tnc-message",
|
||||
arq="transmission",
|
||||
status="waiting",
|
||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||
)
|
||||
|
||||
# wait while timeout not reached and our busy state is busy
|
||||
channel_busy_timeout = time.time() + 30
|
||||
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
||||
threading.Event().wait(0.01)
|
||||
|
||||
# if channel busy timeout reached, stop connecting
|
||||
if time.time() > channel_busy_timeout:
|
||||
self.log.warning("[TNC] Channel busy, try again later...")
|
||||
static.ARQ_SESSION_STATE = "failed"
|
||||
self.send_data_to_socket_queue(
|
||||
freedata="tnc-message",
|
||||
arq="transmission",
|
||||
status="failed",
|
||||
reason="busy",
|
||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||
)
|
||||
static.ARQ_SESSION_STATE = "disconnected"
|
||||
return False
|
||||
|
||||
self.enqueue_frame_for_tx([connection_frame], c2_mode=FREEDV_MODE.datac0.value, copies=1, repeat_delay=0)
|
||||
|
||||
timeout = time.time() + 3
|
||||
|
|
Loading…
Reference in a new issue