fixed protocol

This commit is contained in:
DJ2LS 2024-03-30 21:20:29 +01:00
parent aacc09f936
commit 158d43a60f
5 changed files with 16 additions and 43 deletions

View file

@ -114,7 +114,7 @@ class ARQSessionIRS(arq_session.ARQSession):
self.dxcall,
self.version,
self.snr, flag_abort=self.abort)
self.launch_transmit_and_wait(ack_frame, self.TIMEOUT_CONNECT, mode=FREEDV_MODE.signalling_ack)
self.launch_transmit_and_wait(ack_frame, self.TIMEOUT_CONNECT, mode=FREEDV_MODE.signalling)
if not self.abort:
self.set_state(IRS_State.OPEN_ACK_SENT)
return None, None
@ -172,27 +172,21 @@ class ARQSessionIRS(arq_session.ARQSession):
self.calibrate_speed_settings(burst_frame=burst_frame)
ack = self.frame_factory.build_arq_burst_ack(
self.id,
#self.received_bytes,
self.speed_level,
#self.frames_per_burst,
#self.snr,
flag_abort=self.abort
)
self.set_state(IRS_State.BURST_REPLY_SENT)
self.launch_transmit_and_wait(ack, self.TIMEOUT_DATA, mode=FREEDV_MODE.signalling)
self.launch_transmit_and_wait(ack, self.TIMEOUT_DATA, mode=FREEDV_MODE.signalling_ack)
return None, None
if self.final_crc_matches():
self.log("All data received successfully!")
ack = self.frame_factory.build_arq_burst_ack(self.id,
self.received_bytes,
self.speed_level,
self.frames_per_burst,
self.snr,
flag_final=True,
flag_checksum=True)
self.transmit_frame(ack, mode=FREEDV_MODE.signalling)
self.transmit_frame(ack, mode=FREEDV_MODE.signalling_ack)
self.log("ACK sent")
self.session_ended = time.time()
self.set_state(IRS_State.ENDED)

View file

@ -25,7 +25,7 @@ class FREEDV_MODE(Enum):
Enumeration for codec2 modes and names
"""
signalling = 19
signalling_ack = 20
signalling_ack = 19
datac0 = 14
datac1 = 10
datac3 = 12

View file

@ -28,7 +28,6 @@ class DataFrameFactory:
self._load_broadcast_templates()
self._load_ping_templates()
self._load_fec_templates()
self._load_arq_templates()
self._load_p2p_connection_templates()
@ -73,26 +72,6 @@ class DataFrameFactory:
"snr": 1,
}
def _load_fec_templates(self):
# fec wakeup frame
self.template_list[FR_TYPE.FEC_WAKEUP.value] = {
"frame_length": self.LENGTH_SIG0_FRAME,
"origin": 6,
"mode": 1,
"n_bursts": 1,
}
# fec frame
self.template_list[FR_TYPE.FEC.value] = {
"frame_length": self.LENGTH_SIG0_FRAME,
"data": self.LENGTH_SIG0_FRAME - 1
}
# fec is writing frame
self.template_list[FR_TYPE.IS_WRITING.value] = {
"frame_length": self.LENGTH_SIG0_FRAME,
"origin": 6
}
def _load_arq_templates(self):
@ -477,6 +456,8 @@ class DataFrameFactory:
)
def build_arq_burst_ack(self, session_id: bytes, speed_level: int, flag_final=False, flag_checksum=False, flag_abort=False):
print(session_id)
print(speed_level)
flag = 0b00000000
if flag_final:
flag = helpers.set_flag(flag, 'FINAL', True, self.ARQ_FLAGS)
@ -489,12 +470,10 @@ class DataFrameFactory:
payload = {
"session_id": session_id.to_bytes(1, 'big'),
#"offset": offset.to_bytes(4, 'big'),
"speed_level": speed_level.to_bytes(1, 'big'),
#"frames_per_burst": frames_per_burst.to_bytes(1, 'big'),
#"snr": helpers.snr_to_bytes(snr),
"flag": flag.to_bytes(1, 'big'),
}
print(payload)
return self.construct(FR_TYPE.ARQ_BURST_ACK, payload)
def build_p2p_connection_connect(self, destination, origin, session_id):

View file

@ -46,9 +46,9 @@ class DISPATCHER():
FR_TYPE.PING_ACK.value: {"class": FrameHandler, "name": "PING ACK"},
FR_TYPE.PING.value: {"class": PingFrameHandler, "name": "PING"},
FR_TYPE.QRV.value: {"class": FrameHandler, "name": "QRV"},
FR_TYPE.IS_WRITING.value: {"class": FrameHandler, "name": "IS_WRITING"},
FR_TYPE.FEC.value: {"class": FrameHandler, "name": "FEC"},
FR_TYPE.FEC_WAKEUP.value: {"class": FrameHandler, "name": "FEC WAKEUP"},
#FR_TYPE.IS_WRITING.value: {"class": FrameHandler, "name": "IS_WRITING"},
#FR_TYPE.FEC.value: {"class": FrameHandler, "name": "FEC"},
#FR_TYPE.FEC_WAKEUP.value: {"class": FrameHandler, "name": "FEC WAKEUP"},
}
def __init__(self, config, event_manager, states, modem):

View file

@ -22,16 +22,16 @@ class FRAME_TYPE(Enum):
P2P_CONNECTION_PAYLOAD_ACK = 35
P2P_CONNECTION_DISCONNECT = 36
P2P_CONNECTION_DISCONNECT_ACK = 37
MESH_BROADCAST = 100
MESH_SIGNALLING_PING = 101
MESH_SIGNALLING_PING_ACK = 102
#MESH_BROADCAST = 100
#MESH_SIGNALLING_PING = 101
#MESH_SIGNALLING_PING_ACK = 102
CQ = 200
QRV = 201
PING = 210
PING_ACK = 211
IS_WRITING = 215
#IS_WRITING = 215
BEACON = 250
FEC = 251
FEC_WAKEUP = 252
#FEC = 251
#FEC_WAKEUP = 252
IDENT = 254
TEST_FRAME = 255