mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
from queue import Queue
|
|
import frame_handler
|
|
from event_manager import EventManager
|
|
from state_manager import StateManager
|
|
from modem_frametypes import FRAME_TYPE as FR
|
|
from arq_session_irs import ARQSessionIRS
|
|
from arq_session_iss import ARQSessionISS
|
|
|
|
class ARQFrameHandler(frame_handler.FrameHandler):
|
|
|
|
def follow_protocol(self):
|
|
# self.details == {'frame': {'frame_type': 'BURST_01', 'frame_type_int': 1, 'n_frames_per_burst': 1, 'session_id': 31, 'data': b'Hello world!'}, 'snr': 0, 'frequency_offset': 0, 'freedv_inst': None, 'bytes_per_frame': 15}
|
|
frame = self.details['frame']
|
|
snr = self.details["snr"]
|
|
frequency_offset = self.details["frequency_offset"]
|
|
|
|
# ARQ session open received
|
|
if frame['frame_type_int'] == FR.ARQ_SESSION_OPEN.value:
|
|
session = ARQSessionIRS(self.config,
|
|
self.tx_frame_queue,
|
|
frame['origin'],
|
|
frame['session_id'])
|
|
self.states.register_arq_irs_session(session)
|
|
session.run()
|
|
|
|
# ARQ session open ack received
|
|
elif frame['frame_type_int'] == FR.ARQ_SESSION_OPEN_ACK.value:
|
|
iss_session:ARQSessionISS = self.states.get_arq_iss_session(frame['session_id'])
|
|
iss_session.on_connection_ack_received(frame)
|
|
|
|
# ARQ session data frame received
|
|
elif frame['frame_type_int'] == FR.BURST_FRAME.value:
|
|
print("received data frame....")
|
|
print(frame)
|
|
|
|
irs_session:ARQSessionIRS = self.states.get_arq_irs_session(frame['session_id'])
|
|
irs_session.on_data_received(frame)
|
|
irs_session.rx_data_chain(frame, snr, frequency_offset)
|