mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
first connect, cq and ping handler
This commit is contained in:
parent
55d56b8e83
commit
812e00a403
3 changed files with 78 additions and 9 deletions
|
@ -17,6 +17,9 @@ modem = modem.RF()
|
|||
import helpers
|
||||
|
||||
|
||||
#############################################################################################################
|
||||
# ARQ DATA HANDLER
|
||||
#############################################################################################################
|
||||
|
||||
def data_received(data_in):
|
||||
|
||||
|
@ -440,14 +443,46 @@ def burst_rpt_received(data_in):
|
|||
missing = missing_area[i:i+2]
|
||||
static.ARQ_RPT_FRAMES.insert(0,missing)
|
||||
|
||||
#############################################################################################################
|
||||
# ARQ CONNECT HANDLER
|
||||
#############################################################################################################
|
||||
|
||||
def arq_connect(callsign):
|
||||
logging.info("CONNECTING ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ callsign + "]")
|
||||
frame_type = bytes([220])
|
||||
connection_frame = frame_type + static.MYCALLSIGN
|
||||
|
||||
TRANSMIT_CONNECT_THREAD = threading.Thread(target=modem.transmit_signalling, args=[connection_frame], name="TRANSMIT_ARQ")
|
||||
TRANSMIT_CONNECT_THREAD.start()
|
||||
|
||||
def arq_received_connect(data_in):
|
||||
dxcallsign = data_in[1:6]
|
||||
static.DXCALLSIGN = bytes(dxcallsign)
|
||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||
logging.info("CONNECTING ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ str(static.DXCALLSIGN, 'utf-8') + "]")
|
||||
|
||||
frame_type = bytes([221])
|
||||
connection_frame = frame_type + static.MYCALLSIGN
|
||||
TRANSMIT_CONNECT_THREAD = threading.Thread(target=modem.transmit_signalling, args=[connection_frame], name="TRANSMIT_ARQ")
|
||||
TRANSMIT_CONNECT_THREAD.start()
|
||||
|
||||
def arq_received_connect_keep_alive(data_in):
|
||||
logging.info("CONNECTED ["+ str(static.MYCALLSIGN, 'utf-8') + "] >< ["+ str(static.DXCALLSIGN, 'utf-8') + "]")
|
||||
frame_type = bytes([221])
|
||||
connection_frame = frame_type + static.MYCALLSIGN
|
||||
TRANSMIT_CONNECT_THREAD = threading.Thread(target=modem.transmit_signalling, args=[connection_frame], name="TRANSMIT_ARQ")
|
||||
TRANSMIT_CONNECT_THREAD.start()
|
||||
|
||||
|
||||
#############################################################################################################
|
||||
# PING HANDLER
|
||||
#############################################################################################################
|
||||
|
||||
def transmit_ping(callsign):
|
||||
static.DXCALLSIGN = bytes(callsign, 'utf-8')
|
||||
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] > ["+ callsign + "]")
|
||||
|
||||
frame_type = bytes([2])
|
||||
frame_type = bytes([210])
|
||||
ping_payload = b'PING'
|
||||
|
||||
ping_frame = frame_type + ping_payload
|
||||
|
@ -458,10 +493,10 @@ def transmit_ping(callsign):
|
|||
def received_ping(data_in):
|
||||
logging.info("TX PING ACK")
|
||||
|
||||
frame_type = bytes([3])
|
||||
frame_type = bytes([211])
|
||||
ping_payload = b'PING_ACK'
|
||||
|
||||
ping_frame = frame_type + ping_payload
|
||||
ping_frame = frame_type + static.MYCALLSIGN + ping_payload
|
||||
|
||||
TRANSMIT_PING_THREAD = threading.Thread(target=modem.transmit_signalling, args=[ping_frame], name="TRANSMIT_ARQ")
|
||||
TRANSMIT_PING_THREAD.start()
|
||||
|
@ -469,12 +504,20 @@ def received_ping(data_in):
|
|||
|
||||
|
||||
def received_ping_ack(data_in):
|
||||
logging.info("PING ACK")
|
||||
|
||||
dxcallsign = data_in[1:6]
|
||||
static.DXCALLSIGN = bytes(dxcallsign)
|
||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||
logging.info("PING ACK [" + str(static.DXCALLSIGN) + "]>[" + str(static.MYCALLSIGN) + "]")
|
||||
static.TNC_STATE = 'IDLE'
|
||||
|
||||
#############################################################################################################
|
||||
# BROADCAST HANDLER
|
||||
#############################################################################################################
|
||||
|
||||
def transmit_cq():
|
||||
logging.info("CQ CQ CQ")
|
||||
frame_type = bytes([1])
|
||||
frame_type = bytes([200])
|
||||
print(frame_type)
|
||||
cq_frame = frame_type + static.MYCALLSIGN
|
||||
modem.transmit_signalling(cq_frame)
|
||||
|
|
17
modem.py
17
modem.py
|
@ -395,19 +395,30 @@ class RF():
|
|||
data_handler.burst_rpt_received(signalling_bytes_out[:-2])
|
||||
|
||||
# CQ FRAME
|
||||
elif frametype == 1:
|
||||
elif frametype == 200:
|
||||
logging.info("CQ RECEIVED....")
|
||||
|
||||
# PING FRAME
|
||||
elif frametype == 2:
|
||||
elif frametype == 210:
|
||||
logging.debug("PING RECEIVED....")
|
||||
data_handler.received_ping(signalling_bytes_out[:-2])
|
||||
|
||||
# PING ACK
|
||||
elif frametype == 3:
|
||||
elif frametype == 211:
|
||||
logging.debug("PING ACK RECEIVED....")
|
||||
data_handler.received_ping_ack(signalling_bytes_out[:-2])
|
||||
|
||||
# ARQ CONNECT
|
||||
elif frametype == 220:
|
||||
logging.debug("ARQ CONNECT RECEIVED....")
|
||||
data_handler.arq_received_connect(signalling_bytes_out[:-2])
|
||||
|
||||
# ARQ CONNECT ACK / KEEP ALIVE
|
||||
elif frametype == 221:
|
||||
logging.debug("ARQ CONNECT ACK RECEIVED / KEEP ALIVE....")
|
||||
data_handler.arq_received_connect_keep_alive(signalling_bytes_out[:-2])
|
||||
|
||||
|
||||
else:
|
||||
logging.info("OTHER FRAME: " + str(signalling_bytes_out[:-2]))
|
||||
print(frametype)
|
||||
|
|
17
static.py
17
static.py
|
@ -16,7 +16,7 @@ DXCALLSIGN_CRC8 = b'A'
|
|||
MYGRID = b''
|
||||
|
||||
|
||||
TNC_STATE = b'IDLE'
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -143,11 +143,26 @@ ARQ_N_SENT_FRAMES = 0 #counter for already sent frames
|
|||
# RECEIVING_SIGNALLING
|
||||
# SENDING_ACK
|
||||
# ACK_RECEIVED
|
||||
|
||||
# CONNECTED
|
||||
# DISCONNECTED
|
||||
# CONNECTING
|
||||
# DISCONNECTING
|
||||
ARQ_STATE = 'RECEIVING_SIGNALLING'
|
||||
|
||||
# RECEIVING_SIGNALLING
|
||||
# RECEIVING_DATA_10
|
||||
# RECEIVING_DATA_11
|
||||
# RECEIVING_DATA_12
|
||||
CHANNEL_STATE = 'RECEIVING_SIGNALLING'
|
||||
|
||||
# IDLE
|
||||
# CONNECTING
|
||||
# DISCONNECTING
|
||||
TNC_STATE = b'IDLE'
|
||||
|
||||
|
||||
|
||||
# ------- TX BUFFER
|
||||
TX_BUFFER_SIZE = 0
|
||||
TX_BUFFER = []
|
||||
|
|
Loading…
Reference in a new issue