mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
timeout for open data channel and one click data
This commit is contained in:
parent
b65dd36cc0
commit
e2f8fb5f53
|
@ -465,9 +465,7 @@ def get_n_frames_per_burst():
|
||||||
|
|
||||||
|
|
||||||
def get_best_mode_for_transmission():
|
def get_best_mode_for_transmission():
|
||||||
|
mode = 10
|
||||||
mode = 11
|
|
||||||
|
|
||||||
return mode
|
return mode
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,9 +498,17 @@ def burst_rpt_received(data_in):
|
||||||
# ############################################################################################################
|
# ############################################################################################################
|
||||||
|
|
||||||
|
|
||||||
async def arq_open_data_channel():
|
def open_dc_and_transmit(data_out):
|
||||||
|
if not static.ARQ_READY_FOR_DATA:
|
||||||
|
asyncio.run(arq_open_data_channel())
|
||||||
|
# wait until data channel is open
|
||||||
|
while not static.ARQ_READY_FOR_DATA:
|
||||||
|
time.sleep(0.01)
|
||||||
|
# transmit data
|
||||||
|
arq_transmit(data_out)
|
||||||
|
|
||||||
logging.info("DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]>> <<[" + str(static.DXCALLSIGN, 'utf-8') + "] [BER." + str(static.BER) + "]")
|
|
||||||
|
async def arq_open_data_channel():
|
||||||
|
|
||||||
static.ARQ_DATA_CHANNEL_MODE = get_best_mode_for_transmission()
|
static.ARQ_DATA_CHANNEL_MODE = get_best_mode_for_transmission()
|
||||||
static.ARQ_DATA_CHANNEL_LAST_RECEIVED = int(time.time())
|
static.ARQ_DATA_CHANNEL_LAST_RECEIVED = int(time.time())
|
||||||
|
@ -517,9 +523,20 @@ async def arq_open_data_channel():
|
||||||
connection_frame[3:9] = static.MYCALLSIGN
|
connection_frame[3:9] = static.MYCALLSIGN
|
||||||
connection_frame[12:13] = bytes([static.ARQ_DATA_CHANNEL_MODE])
|
connection_frame[12:13] = bytes([static.ARQ_DATA_CHANNEL_MODE])
|
||||||
|
|
||||||
modem.transmit_signalling(connection_frame)
|
while not static.ARQ_READY_FOR_DATA:
|
||||||
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
for attempt in range(0,3):
|
||||||
time.sleep(0.01)
|
logging.info("DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]>> <<[" + str(static.DXCALLSIGN, 'utf-8') + "] A:[" + str(attempt + 1) + "/" + str(3) + "]")
|
||||||
|
modem.transmit_signalling(connection_frame)
|
||||||
|
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
timeout = time.time() + 5
|
||||||
|
while time.time() < timeout:
|
||||||
|
# break if data channel is openend
|
||||||
|
if static.ARQ_READY_FOR_DATA:
|
||||||
|
break
|
||||||
|
if static.ARQ_READY_FOR_DATA:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def arq_received_data_channel_opener(data_in):
|
def arq_received_data_channel_opener(data_in):
|
||||||
|
|
13
sock.py
13
sock.py
|
@ -104,15 +104,24 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||||
asyncio.run(data_handler.arq_open_data_channel())
|
asyncio.run(data_handler.arq_open_data_channel())
|
||||||
|
|
||||||
|
|
||||||
if received_json["command"] == "ARQ:DATA" and static.ARQ_READY_FOR_DATA == True: # and static.ARQ_STATE == 'CONNECTED' :
|
if received_json["command"] == "ARQ:DATA":# and static.ARQ_READY_FOR_DATA == True: # and static.ARQ_STATE == 'CONNECTED' :
|
||||||
static.TNC_STATE = 'BUSY'
|
static.TNC_STATE = 'BUSY'
|
||||||
|
|
||||||
#on a new transmission we reset the timer
|
#on a new transmission we reset the timer
|
||||||
static.ARQ_START_OF_TRANSMISSION = int(time.time())
|
static.ARQ_START_OF_TRANSMISSION = int(time.time())
|
||||||
|
|
||||||
|
|
||||||
|
dxcallsign = received_json["dxcallsign"]
|
||||||
|
static.DXCALLSIGN = bytes(dxcallsign, 'utf-8')
|
||||||
|
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||||
|
|
||||||
|
|
||||||
data_out = bytes(received_json["data"], 'utf-8')
|
data_out = bytes(received_json["data"], 'utf-8')
|
||||||
|
|
||||||
ARQ_DATA_THREAD = threading.Thread(target=data_handler.arq_transmit, args=[data_out], name="ARQ_DATA")
|
#ARQ_DATA_THREAD = threading.Thread(target=data_handler.arq_transmit, args=[data_out], name="ARQ_DATA")
|
||||||
|
#ARQ_DATA_THREAD.start()
|
||||||
|
|
||||||
|
ARQ_DATA_THREAD = threading.Thread(target=data_handler.open_dc_and_transmit, args=[data_out], name="ARQ_DATA")
|
||||||
ARQ_DATA_THREAD.start()
|
ARQ_DATA_THREAD.start()
|
||||||
# asyncio.run(data_handler.arq_transmit(data_out))
|
# asyncio.run(data_handler.arq_transmit(data_out))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue