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']
|
2023-12-14 16:29:04 +00:00
|
|
|
session_id = frame['session_id']
|
2023-12-12 08:46:22 +00:00
|
|
|
snr = self.details["snr"]
|
|
|
|
frequency_offset = self.details["frequency_offset"]
|
2023-12-05 14:40:04 +00:00
|
|
|
|
2023-12-12 19:46:22 +00:00
|
|
|
if frame['frame_type_int'] == FR.ARQ_SESSION_OPEN.value:
|
2023-12-14 16:29:04 +00:00
|
|
|
|
2023-12-13 17:27:55 +00:00
|
|
|
# Lost OPEN_ACK case .. ISS will retry opening a session
|
2023-12-14 16:29:04 +00:00
|
|
|
if session_id in self.states.arq_irs_sessions:
|
|
|
|
session = self.states.arq_irs_sessions[session_id]
|
|
|
|
|
2023-12-13 17:27:55 +00:00
|
|
|
# Normal case when receiving a SESSION_OPEN for the first time
|
|
|
|
else:
|
2023-12-15 23:51:57 +00:00
|
|
|
session = ARQSessionIRS(self.config,
|
|
|
|
self.modem,
|
2023-12-13 17:27:55 +00:00
|
|
|
frame['origin'],
|
2023-12-14 16:29:04 +00:00
|
|
|
session_id)
|
2023-12-13 17:27:55 +00:00
|
|
|
self.states.register_arq_irs_session(session)
|
2023-12-12 21:05:32 +00:00
|
|
|
|
2023-12-14 16:29:04 +00:00
|
|
|
elif frame['frame_type_int'] in [
|
|
|
|
FR.ARQ_SESSION_INFO.value,
|
|
|
|
FR.ARQ_BURST_FRAME.value,
|
|
|
|
]:
|
|
|
|
session = self.states.get_arq_irs_session(session_id)
|
2023-12-12 21:33:17 +00:00
|
|
|
|
2023-12-14 16:29:04 +00:00
|
|
|
elif frame['frame_type_int'] in [
|
|
|
|
FR.ARQ_SESSION_OPEN_ACK.value,
|
|
|
|
FR.ARQ_SESSION_INFO_ACK.value,
|
|
|
|
FR.ARQ_BURST_ACK.value,
|
|
|
|
FR.ARQ_DATA_ACK_NACK.value
|
|
|
|
]:
|
|
|
|
session = self.states.get_arq_iss_session(session_id)
|
2023-12-09 12:28:32 +00:00
|
|
|
|
2023-12-12 21:33:17 +00:00
|
|
|
else:
|
|
|
|
self.logger.warning("DISCARDING FRAME", frame=frame)
|
2023-12-14 16:29:04 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
session.set_details(snr, frequency_offset)
|
|
|
|
session.on_frame_received(frame)
|