From 8337a5945d114a6f27ac84c8e317181d52926fa2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 21 Nov 2024 12:30:07 +0100 Subject: [PATCH] Internal interface config handling for AX25KISSInterface --- RNS/Interfaces/AX25KISSInterface.py | 22 ++++++++++++- RNS/Reticulum.py | 50 ++--------------------------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index 483c562..964cd68 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -59,6 +59,7 @@ class AX25(): class AX25KISSInterface(Interface): MAX_CHUNK = 32768 BITRATE_GUESS = 1200 + DEFAULT_IFAC_SIZE = 8 owner = None port = None @@ -68,7 +69,7 @@ class AX25KISSInterface(Interface): stopbits = None serial = None - def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control): + def __init__(self, owner, configuration): import importlib if importlib.util.find_spec('serial') != None: import serial @@ -79,6 +80,25 @@ class AX25KISSInterface(Interface): super().__init__() + c = configuration + name = c["name"] + preamble = int(c["preamble"]) if "preamble" in c else None + txtail = int(c["txtail"]) if "txtail" in c else None + persistence = int(c["persistence"]) if "persistence" in c else None + slottime = int(c["slottime"]) if "slottime" in c else None + flow_control = c.as_bool("flow_control") if "flow_control" in c else False + port = c["port"] if "port" in c else None + speed = int(c["speed"]) if "speed" in c else 9600 + databits = int(c["databits"]) if "databits" in c else 8 + parity = c["parity"] if "parity" in c else "N" + stopbits = int(c["stopbits"]) if "stopbits" in c else 1 + + callsign = c["callsign"] if "callsign" in c else "" + ssid = int(c["ssid"]) if "ssid" in c else -1 + + if port == None: + raise ValueError("No port specified for serial interface") + self.HW_MTU = 564 self.pyserial = serial diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index bd7a3ad..fea7e63 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -627,54 +627,8 @@ class Reticulum: interface_post_init(interface) if c["type"] == "AX25KISSInterface": - preamble = int(c["preamble"]) if "preamble" in c else None - txtail = int(c["txtail"]) if "txtail" in c else None - persistence = int(c["persistence"]) if "persistence" in c else None - slottime = int(c["slottime"]) if "slottime" in c else None - flow_control = c.as_bool("flow_control") if "flow_control" in c else False - port = c["port"] if "port" in c else None - speed = int(c["speed"]) if "speed" in c else 9600 - databits = int(c["databits"]) if "databits" in c else 8 - parity = c["parity"] if "parity" in c else "N" - stopbits = int(c["stopbits"]) if "stopbits" in c else 1 - - callsign = c["callsign"] if "callsign" in c else "" - ssid = int(c["ssid"]) if "ssid" in c else -1 - - if port == None: - raise ValueError("No port specified for serial interface") - - interface = AX25KISSInterface.AX25KISSInterface( - RNS.Transport, - name, - callsign, - ssid, - port, - speed, - databits, - parity, - stopbits, - preamble, - txtail, - persistence, - slottime, - flow_control - ) - - if "outgoing" in c and c.as_bool("outgoing") == False: - interface.OUT = False - else: - interface.OUT = True - - interface.mode = interface_mode - - interface.announce_cap = announce_cap - if configured_bitrate: - interface.bitrate = configured_bitrate - if ifac_size != None: - interface.ifac_size = ifac_size - else: - interface.ifac_size = 8 + interface = AX25KISSInterface.AX25KISSInterface(RNS.Transport, interface_config) + interface_post_init(interface) if c["type"] == "RNodeInterface": frequency = int(c["frequency"]) if "frequency" in c else None