timeout for open data channel and one click data

This commit is contained in:
DJ2LS 2021-03-18 14:37:42 +01:00 committed by GitHub
parent b65dd36cc0
commit e2f8fb5f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 11 deletions

View file

@ -464,10 +464,8 @@ def get_n_frames_per_burst():
return n_frames_per_burst
def get_best_mode_for_transmission():
mode = 11
def get_best_mode_for_transmission():
mode = 10
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_LAST_RECEIVED = int(time.time())
@ -517,9 +523,20 @@ async def arq_open_data_channel():
connection_frame[3:9] = static.MYCALLSIGN
connection_frame[12:13] = bytes([static.ARQ_DATA_CHANNEL_MODE])
modem.transmit_signalling(connection_frame)
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
time.sleep(0.01)
while not static.ARQ_READY_FOR_DATA:
for attempt in range(0,3):
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):

13
sock.py
View file

@ -104,15 +104,24 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
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'
#on a new transmission we reset the timer
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')
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()
# asyncio.run(data_handler.arq_transmit(data_out))