mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
ARQ WIP - check if frame is for us
This commit is contained in:
parent
b941eda41a
commit
022d7ef258
|
@ -191,6 +191,5 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
self.set_state(ISS_State.ABORTED)
|
self.set_state(ISS_State.ABORTED)
|
||||||
# break actual retries
|
# break actual retries
|
||||||
self.event_frame_received.set()
|
self.event_frame_received.set()
|
||||||
|
|
||||||
self.event_manager.send_arq_session_finished(
|
self.event_manager.send_arq_session_finished(
|
||||||
True, self.id, self.dxcall, len(self.data), False, self.state.name)
|
True, self.id, self.dxcall, len(self.data), False, self.state.name)
|
|
@ -97,41 +97,3 @@ class DISPATCHER():
|
||||||
if data[:1] == FR_TYPE.ARQ_SESSION_OPEN:
|
if data[:1] == FR_TYPE.ARQ_SESSION_OPEN:
|
||||||
return data[13:14]
|
return data[13:14]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,42 @@ class FrameHandler():
|
||||||
'bytes_per_frame': 0
|
'bytes_per_frame': 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def is_frame_for_me(self):
|
||||||
|
call_with_ssid = self.config['STATION']['mycall'] + "-" + str(self.config['STATION']['myssid'])
|
||||||
|
ft = self.details['frame']['frame_type']
|
||||||
|
print(self.details)
|
||||||
|
|
||||||
|
# Check for callsign checksum
|
||||||
|
if ft in ['ARQ_SESSION_OPEN', 'ARQ_SESSION_OPEN_ACK', 'PING', 'PING_ACK']:
|
||||||
|
valid, mycallsign = helpers.check_callsign(
|
||||||
|
call_with_ssid,
|
||||||
|
self.details["frame"]["destination_crc"],
|
||||||
|
self.config['STATION']['ssid_list'])
|
||||||
|
|
||||||
|
# Check for session id on IRS side
|
||||||
|
elif ft in ['ARQ_SESSION_INFO', 'ARQ_BURST_FRAME', 'ARQ_STOP']:
|
||||||
|
session_id = self.details['frame']['session_id']
|
||||||
|
if session_id in self.states.arq_irs_sessions:
|
||||||
|
valid = True
|
||||||
|
|
||||||
|
# Check for session id on ISS side
|
||||||
|
elif ft in ['ARQ_SESSION_INFO_ACK', 'ARQ_BURST_ACK', 'ARQ_STOP_ACK']:
|
||||||
|
session_id = self.details['frame']['session_id']
|
||||||
|
if session_id in self.states.arq_iss_sessions:
|
||||||
|
valid = True
|
||||||
|
else:
|
||||||
|
valid = False
|
||||||
|
|
||||||
|
if not valid:
|
||||||
|
self.logger.info(f"[Frame handler] {ft} received but not for us.")
|
||||||
|
|
||||||
|
return valid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def should_respond(self):
|
||||||
|
return self.is_frame_for_me()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_activity_list(self):
|
def add_to_activity_list(self):
|
||||||
|
|
|
@ -9,6 +9,10 @@ from arq_session_iss import ARQSessionISS
|
||||||
class ARQFrameHandler(frame_handler.FrameHandler):
|
class ARQFrameHandler(frame_handler.FrameHandler):
|
||||||
|
|
||||||
def follow_protocol(self):
|
def follow_protocol(self):
|
||||||
|
|
||||||
|
if not self.should_respond():
|
||||||
|
return
|
||||||
|
|
||||||
frame = self.details['frame']
|
frame = self.details['frame']
|
||||||
session_id = frame['session_id']
|
session_id = frame['session_id']
|
||||||
snr = self.details["snr"]
|
snr = self.details["snr"]
|
||||||
|
|
|
@ -4,21 +4,20 @@ import data_frame_factory
|
||||||
|
|
||||||
class PingFrameHandler(frame_handler.FrameHandler):
|
class PingFrameHandler(frame_handler.FrameHandler):
|
||||||
|
|
||||||
def is_frame_for_me(self):
|
#def is_frame_for_me(self):
|
||||||
call_with_ssid = self.config['STATION']['mycall'] + "-" + str(self.config['STATION']['myssid'])
|
# call_with_ssid = self.config['STATION']['mycall'] + "-" + str(self.config['STATION']['myssid'])
|
||||||
valid, mycallsign = helpers.check_callsign(
|
# valid, mycallsign = helpers.check_callsign(
|
||||||
call_with_ssid,
|
# call_with_ssid,
|
||||||
self.details["frame"]["destination_crc"],
|
# self.details["frame"]["destination_crc"],
|
||||||
self.config['STATION']['ssid_list'])
|
# self.config['STATION']['ssid_list'])
|
||||||
|
|
||||||
if not valid:
|
# if not valid:
|
||||||
ft = self.details['frame']['frame_type']
|
# ft = self.details['frame']['frame_type']
|
||||||
self.logger.info(f"[Modem] {ft} received but not for us.")
|
# self.logger.info(f"[Modem] {ft} received but not for us.")
|
||||||
|
# return valid
|
||||||
return valid
|
|
||||||
|
|
||||||
def should_respond(self):
|
#def should_respond(self):
|
||||||
return self.is_frame_for_me()
|
# return self.is_frame_for_me()
|
||||||
|
|
||||||
def follow_protocol(self):
|
def follow_protocol(self):
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
self.establishChannels()
|
self.establishChannels()
|
||||||
params = {
|
params = {
|
||||||
'dxcall': "DJ2LS-3",
|
'dxcall': "XX1XXX-1",
|
||||||
'data': base64.b64encode(bytes("Hello world!", encoding="utf-8")),
|
'data': base64.b64encode(bytes("Hello world!", encoding="utf-8")),
|
||||||
}
|
}
|
||||||
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
@ -142,7 +142,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
self.establishChannels()
|
self.establishChannels()
|
||||||
params = {
|
params = {
|
||||||
'dxcall': "DJ2LS-3",
|
'dxcall': "XX1XXX-1",
|
||||||
'data': base64.b64encode(np.random.bytes(1000)),
|
'data': base64.b64encode(np.random.bytes(1000)),
|
||||||
}
|
}
|
||||||
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
@ -156,7 +156,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
self.establishChannels()
|
self.establishChannels()
|
||||||
params = {
|
params = {
|
||||||
'dxcall': "DJ2LS-3",
|
'dxcall': "XX1XXX-1",
|
||||||
'data': base64.b64encode(np.random.bytes(100)),
|
'data': base64.b64encode(np.random.bytes(100)),
|
||||||
}
|
}
|
||||||
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
@ -174,7 +174,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
self.establishChannels()
|
self.establishChannels()
|
||||||
params = {
|
params = {
|
||||||
'dxcall': "DJ2LS-3",
|
'dxcall': "XX1XXX-1",
|
||||||
'data': base64.b64encode(np.random.bytes(100)),
|
'data': base64.b64encode(np.random.bytes(100)),
|
||||||
}
|
}
|
||||||
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
|
Loading…
Reference in a new issue