mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
introduced static.LISTEN state
This commit is contained in:
parent
b57fb299b4
commit
65cfd52d81
3 changed files with 48 additions and 21 deletions
|
@ -580,12 +580,19 @@ class RF:
|
|||
audiobuffer.pop(nin)
|
||||
nin = codec2.api.freedv_nin(freedv)
|
||||
if nbytes == bytes_per_frame:
|
||||
# process commands only if static.LISTEN = True
|
||||
if static.LISTEN:
|
||||
self.log.debug(
|
||||
"[MDM] [demod_audio] Pushing received data to received_queue"
|
||||
)
|
||||
self.modem_received_queue.put([bytes_out, freedv, bytes_per_frame])
|
||||
self.get_scatter(freedv)
|
||||
self.calculate_snr(freedv)
|
||||
else:
|
||||
self.log.warning(
|
||||
"[MDM] [demod_audio] received frame but ignored processing",
|
||||
listen=static.LISTEN
|
||||
)
|
||||
except Exception as e:
|
||||
self.log.warning("[MDM] [demod_audio] Stream not active anymore", e=e)
|
||||
return nin
|
||||
|
@ -680,7 +687,6 @@ class RF:
|
|||
self.sig1_datac0_bytes_per_frame,
|
||||
)
|
||||
|
||||
|
||||
def audio_dat0_datac1(self) -> None:
|
||||
"""Receive data encoded with datac1"""
|
||||
self.dat0_datac1_nin = self.demodulate_audio(
|
||||
|
|
47
tnc/sock.py
47
tnc/sock.py
|
@ -204,6 +204,38 @@ def process_tnc_commands(data):
|
|||
# convert data to json object
|
||||
received_json = json.loads(data)
|
||||
log.debug("[SCK] CMD", command=received_json)
|
||||
|
||||
# ENABLE TNC LISTENING STATE -----------------------------------------------------
|
||||
if received_json["type"] == "set" and received_json["command"] == "listen":
|
||||
try:
|
||||
static.LISTEN = received_json["state"] in ['true', 'True', True, "ON", "on"]
|
||||
command_response("listen", True)
|
||||
|
||||
# if tnc is connected, force disconnect when static.LISTEN == False
|
||||
if not static.LISTEN and static.ARQ_SESSION_STATE not in ["disconnecting", "disconnected", "failed"]:
|
||||
DATA_QUEUE_TRANSMIT.put(["DISCONNECT"])
|
||||
# set early disconnecting state so we can interrupt connection attempts
|
||||
static.ARQ_SESSION_STATE = "disconnecting"
|
||||
command_response("disconnect", True)
|
||||
|
||||
except Exception as err:
|
||||
command_response("listen", False)
|
||||
log.warning(
|
||||
"[SCK] CQ command execution error", e=err, command=received_json
|
||||
)
|
||||
|
||||
# SET ENABLE RESPOND TO CQ -----------------------------------------------------
|
||||
if received_json["type"] == "set" and received_json["command"] == "respond_to_cq":
|
||||
try:
|
||||
static.RESPOND_TO_CQ = received_json["state"] in ['true', 'True', True]
|
||||
command_response("respond_to_cq", True)
|
||||
|
||||
except Exception as err:
|
||||
command_response("respond_to_cq", False)
|
||||
log.warning(
|
||||
"[SCK] CQ command execution error", e=err, command=received_json
|
||||
)
|
||||
|
||||
# SET TX AUDIO LEVEL -----------------------------------------------------
|
||||
if (
|
||||
received_json["type"] == "set"
|
||||
|
@ -221,18 +253,6 @@ def process_tnc_commands(data):
|
|||
command=received_json,
|
||||
)
|
||||
|
||||
# SET ENABLE RESPOND TO CQ -----------------------------------------------------
|
||||
if received_json["type"] == "set" and received_json["command"] == "respond_to_cq":
|
||||
try:
|
||||
static.RESPOND_TO_CQ = received_json["state"] in ['true', 'True', True]
|
||||
command_response("respond_to_cq", True)
|
||||
|
||||
except Exception as err:
|
||||
command_response("respond_to_cq", False)
|
||||
log.warning(
|
||||
"[SCK] CQ command execution error", e=err, command=received_json
|
||||
)
|
||||
|
||||
# TRANSMIT TEST FRAME ----------------------------------------------------
|
||||
if (
|
||||
received_json["type"] == "set"
|
||||
|
@ -372,7 +392,7 @@ def process_tnc_commands(data):
|
|||
# DISCONNECT ----------------------------------------------------------
|
||||
if received_json["type"] == "arq" and received_json["command"] == "disconnect":
|
||||
try:
|
||||
if not static.ARQ_SESSION_STATE in ["disconnecting", "disconnected", "failed"]:
|
||||
if static.ARQ_SESSION_STATE not in ["disconnecting", "disconnected", "failed"]:
|
||||
DATA_QUEUE_TRANSMIT.put(["DISCONNECT"])
|
||||
|
||||
# set early disconnecting state so we can interrupt connection attempts
|
||||
|
@ -558,6 +578,7 @@ def send_tnc_state():
|
|||
"dxcallsign": str(static.DXCALLSIGN, encoding),
|
||||
"dxgrid": str(static.DXGRID, encoding),
|
||||
"hamlib_status": static.HAMLIB_STATUS,
|
||||
"listen": str(static.LISTEN),
|
||||
}
|
||||
|
||||
# add heard stations to heard stations object
|
||||
|
|
|
@ -43,7 +43,7 @@ SOCKET_TIMEOUT: int = 1 # seconds
|
|||
# ---------------------------------
|
||||
SERIAL_DEVICES: list = []
|
||||
# ---------------------------------
|
||||
|
||||
LISTEN: bool = True
|
||||
PTT_STATE: bool = False
|
||||
TRANSMITTING: bool = False
|
||||
|
||||
|
|
Loading…
Reference in a new issue