make arq connection behavior more simple #285

This commit is contained in:
DJ2LS 2022-11-20 00:20:32 +01:00
parent 8f0dd9df8b
commit 03987de194

View file

@ -318,15 +318,15 @@ def process_tnc_commands(data):
dxcallsign = helpers.callsign_to_bytes(dxcallsign) dxcallsign = helpers.callsign_to_bytes(dxcallsign)
dxcallsign = helpers.bytes_to_callsign(dxcallsign) dxcallsign = helpers.bytes_to_callsign(dxcallsign)
if dxcallsign == static.DXCALLSIGN and static.ARQ_SESSION_STATE != "disconnected": if static.ARQ_SESSION_STATE != "disconnected":
command_response("connect", False) command_response("connect", False)
log.warning( log.warning(
"[SCK] Connect command execution error", "[SCK] Connect command execution error",
e="already connected to callsign", e=f"already connected to station:{static.DXCALLSIGN}",
command=received_json, command=received_json,
) )
else: else:
"""
# check if we are going to connect to a different callsign # check if we are going to connect to a different callsign
# if so, then disconnect first # if so, then disconnect first
if dxcallsign != static.DXCALLSIGN and static.ARQ_SESSION_STATE != "disconnected": if dxcallsign != static.DXCALLSIGN and static.ARQ_SESSION_STATE != "disconnected":
@ -343,11 +343,15 @@ def process_tnc_commands(data):
callsign=static.DXCALLSIGN, callsign=static.DXCALLSIGN,
command=received_json, command=received_json,
) )
# set disconnect timeout to 15 seconds to avoid being stuck here if disconnect fails # set disconnect timeout to 15 seconds to avoid being stuck here if disconnect fails
disconnect_timeout = time.time() + 15 disconnect_timeout = time.time() + 15
# wait until disconnected or timeout reached # wait until disconnected or timeout reached
while static.ARQ_SESSION_STATE != 'disconnected' and time.time() < disconnect_timeout: while static.ARQ_SESSION_STATE != 'disconnected' and time.time() < disconnect_timeout:
time.sleep(0.01) time.sleep(0.01)
"""
# finally check again if we are disconnected or failed # finally check again if we are disconnected or failed
if static.ARQ_SESSION_STATE == 'disconnected' or static.ARQ_SESSION_STATE == 'failed': if static.ARQ_SESSION_STATE == 'disconnected' or static.ARQ_SESSION_STATE == 'failed':
@ -379,7 +383,6 @@ def process_tnc_commands(data):
# allow beacon transmission again # allow beacon transmission again
static.BEACON_PAUSE = False static.BEACON_PAUSE = False
# DISCONNECT ---------------------------------------------------------- # DISCONNECT ----------------------------------------------------------
if received_json["type"] == "arq" and received_json["command"] == "disconnect": if received_json["type"] == "arq" and received_json["command"] == "disconnect":
try: try: