FreeDATA/modem/frame_handler_arq.py

26 lines
1 KiB
Python
Raw Normal View History

2023-12-05 14:40:04 +00:00
from queue import Queue
import frame_handler
2023-12-05 17:50:39 +00:00
from event_manager import EventManager
from state_manager import StateManager
2023-12-05 14:40:04 +00:00
from modem_frametypes import FRAME_TYPE as FR
from arq_session_irs import ARQSessionIRS
2023-12-05 18:12:21 +00:00
from arq_session_iss import ARQSessionISS
2023-12-05 14:40:04 +00:00
class ARQFrameHandler(frame_handler.FrameHandler):
def follow_protocol(self):
frame = self.details['frame']
# ARQ session open received
2023-12-05 17:50:39 +00:00
if frame['frame_type_int'] in [FR.ARQ_DC_OPEN_N.value, FR.ARQ_DC_OPEN_W.value]:
session = ARQSessionIRS(self.config,
self.tx_frame_queue,
frame['origin'], frame['session_id'])
2023-12-05 14:40:04 +00:00
self.states.register_arq_irs_session(session)
session.run()
2023-12-05 18:12:21 +00:00
# ARQ session open ack received
if frame['frame_type_int'] in [FR.ARQ_DC_OPEN_ACK_N.value, FR.ARQ_DC_OPEN_ACK_W.value]:
iss_session:ARQSessionISS = self.states.get_arq_iss_session(frame['session_id'])
iss_session.on_connection_ack_received(frame)