check for max bandwidth on session open

This commit is contained in:
DJ2LS 2024-03-24 21:39:44 +01:00
parent 8c224ab7dc
commit 3cb329b379
6 changed files with 22 additions and 12 deletions

View file

@ -2,7 +2,7 @@
"name": "FreeDATA",
"description": "FreeDATA Client application for connecting to FreeDATA server",
"private": true,
"version": "0.14.4-alpha",
"version": "0.14.5-alpha",
"main": "dist-electron/main/index.js",
"scripts": {
"start": "vite",

View file

@ -164,8 +164,9 @@ class ARQSession:
return stats
def get_appropriate_speed_level(self, snr):
maximum_bandwidth = self.config['MODEM']['maximum_bandwidth']
def get_appropriate_speed_level(self, snr, maximum_bandwidth=None):
if maximum_bandwidth is None:
maximum_bandwidth = self.config['MODEM']['maximum_bandwidth']
# Adjust maximum_bandwidth based on special conditions or invalid configurations
if maximum_bandwidth == 0:
@ -176,9 +177,7 @@ class ARQSession:
appropriate_speed_level = min(self.SPEED_LEVEL_DICT.keys())
for level, details in self.SPEED_LEVEL_DICT.items():
if snr >= details['min_snr'] and details['bandwidth'] <= maximum_bandwidth:
# Update appropriate_speed_level to the current level if it meets both SNR and bandwidth criteria
if level > appropriate_speed_level:
appropriate_speed_level = level
if snr >= details['min_snr'] and details['bandwidth'] <= maximum_bandwidth and level > appropriate_speed_level:
appropriate_speed_level = level
return appropriate_speed_level

View file

@ -76,6 +76,8 @@ class ARQSessionIRS(arq_session.ARQSession):
self.received_bytes = 0
self.received_crc = None
self.maximum_bandwidth = 0
self.abort = False
def all_data_received(self):
@ -98,6 +100,12 @@ class ARQSessionIRS(arq_session.ARQSession):
thread_wait.start()
def send_open_ack(self, open_frame):
self.maximum_bandwidth = open_frame['maximum_bandwidth']
# check for maximum bandwidth. If ISS bandwidth is higher than own, then use own
if open_frame['maximum_bandwidth'] > self.config['MODEM']['maximum_bandwidth']:
self.maximum_bandwidth = self.config['MODEM']['maximum_bandwidth']
self.event_manager.send_arq_session_new(
False, self.id, self.dxcall, 0, self.state.name)
ack_frame = self.frame_factory.build_arq_session_open_ack(
@ -211,7 +219,7 @@ class ARQSessionIRS(arq_session.ARQSession):
received_speed_level = 0
latest_snr = self.snr if self.snr else -10
appropriate_speed_level = self.get_appropriate_speed_level(latest_snr)
appropriate_speed_level = self.get_appropriate_speed_level(latest_snr, self.maximum_bandwidth)
modes_to_decode = {}
# Log the latest SNR, current, appropriate speed levels, and the previous speed level

View file

@ -104,9 +104,10 @@ class ARQSessionISS(arq_session.ARQSession):
twr.start()
def start(self):
maximum_bandwidth = self.config['MODEM']['maximum_bandwidth']
self.event_manager.send_arq_session_new(
True, self.id, self.dxcall, self.total_length, self.state.name)
session_open_frame = self.frame_factory.build_arq_session_open(self.dxcall, self.id)
session_open_frame = self.frame_factory.build_arq_session_open(self.dxcall, self.id, maximum_bandwidth)
self.launch_twr(session_open_frame, self.TIMEOUT_CONNECT_ACK, self.RETRIES_CONNECT, mode=FREEDV_MODE.signalling)
self.set_state(ISS_State.OPEN_SENT)

View file

@ -98,6 +98,7 @@ class DataFrameFactory:
"destination_crc": 3,
"origin": 6,
"session_id": 1,
"maximum_bandwidth": 2,
}
self.template_list[FR_TYPE.ARQ_SESSION_OPEN_ACK.value] = {
@ -219,7 +220,7 @@ class DataFrameFactory:
elif key in ["session_id", "speed_level",
"frames_per_burst", "version",
"offset", "total_length", "state", "type"]:
"offset", "total_length", "state", "type", "maximum_bandwidth"]:
extracted_data[key] = int.from_bytes(data, 'big')
elif key in ["snr"]:
@ -328,11 +329,12 @@ class DataFrameFactory:
test_frame[:1] = bytes([FR_TYPE.TEST_FRAME.value])
return test_frame
def build_arq_session_open(self, destination, session_id):
def build_arq_session_open(self, destination, session_id, maximum_bandwidth):
payload = {
"destination_crc": helpers.get_crc_24(destination),
"origin": helpers.callsign_to_bytes(self.myfullcall),
"session_id": session_id.to_bytes(1, 'big'),
"maximum_bandwidth": maximum_bandwidth.to_bytes(2, 'big'),
}
return self.construct(FR_TYPE.ARQ_SESSION_OPEN, payload)

View file

@ -33,7 +33,7 @@ from schedule_manager import ScheduleManager
app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})
sock = Sock(app)
MODEM_VERSION = "0.14.4-alpha"
MODEM_VERSION = "0.14.5-alpha"
# set config file to use
def set_config():