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-08 09:25:26 +00:00
|
|
|
if frame['frame_type_int'] in [FR.ARQ_SESSION_OPEN_N.value, FR.ARQ_SESSION_OPEN_W.value]:
|
2023-12-05 17:50:39 +00:00
|
|
|
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
|
2023-12-08 09:25:26 +00:00
|
|
|
if frame['frame_type_int'] in [FR.ARQ_SESSION_OPEN_ACK_N.value, FR.ARQ_SESSION_OPEN_ACK_W.value]:
|
2023-12-05 18:12:21 +00:00
|
|
|
iss_session:ARQSessionISS = self.states.get_arq_iss_session(frame['session_id'])
|
|
|
|
iss_session.on_connection_ack_received(frame)
|
2023-12-09 12:28:32 +00:00
|
|
|
|
|
|
|
# ARQ session data frame received
|
|
|
|
if frame['frame_type_int'] in [FR.BURST_01.value, FR.BURST_02.value, FR.BURST_03.value, FR.BURST_04.value, FR.BURST_05.value]:
|
|
|
|
print("received data frame....")
|
|
|
|
irs_session:ARQSessionIRS = self.states.get_arq_irs_session(frame['session_id'])
|
|
|
|
irs_session.on_data_received(frame)
|