Skip to content

Commit

Permalink
Internal interface config handling for AX25KISSInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed Nov 21, 2024
1 parent a736b3a commit 8337a59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 49 deletions.
22 changes: 21 additions & 1 deletion RNS/Interfaces/AX25KISSInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AX25():
class AX25KISSInterface(Interface):
MAX_CHUNK = 32768
BITRATE_GUESS = 1200
DEFAULT_IFAC_SIZE = 8

owner = None
port = None
Expand All @@ -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
Expand All @@ -79,6 +80,25 @@ def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, s

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
Expand Down
50 changes: 2 additions & 48 deletions RNS/Reticulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,54 +627,8 @@ def interface_post_init(interface):
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
Expand Down

0 comments on commit 8337a59

Please sign in to comment.