diff --git a/RNS/Interfaces/Android/KISSInterface.py b/RNS/Interfaces/Android/KISSInterface.py index 88514b5..704c9ea 100644 --- a/RNS/Interfaces/Android/KISSInterface.py +++ b/RNS/Interfaces/Android/KISSInterface.py @@ -52,6 +52,7 @@ class KISS(): class KISSInterface(Interface): MAX_CHUNK = 32768 BITRATE_GUESS = 1200 + DEFAULT_IFAC_SIZE = 8 owner = None port = None @@ -61,7 +62,7 @@ class KISSInterface(Interface): stopbits = None serial = None - def __init__(self, owner, name, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control, beacon_interval, beacon_data): + def __init__(self, owner, configuration): import importlib if RNS.vendor.platformutils.is_android(): self.on_android = True @@ -83,6 +84,21 @@ class KISSInterface(Interface): raise SystemError("Android-specific interface was used on non-Android OS") 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 + beacon_interval = int(c["beacon_interval"]) if "beacon_interval" in c else None + beacon_data = c["beacon_data"] if "beacon_data" in c else None self.HW_MTU = 564 diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index 9594acc..8a1a9b9 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -238,6 +238,7 @@ class AndroidBluetoothManager(): class RNodeInterface(Interface): MAX_CHUNK = 32768 + DEFAULT_IFAC_SIZE = 8 FREQ_MIN = 137000000 FREQ_MAX = 1020000000 @@ -341,12 +342,27 @@ class RNodeInterface(Interface): serial.close() - def __init__( - self, owner, name, port, frequency = None, bandwidth = None, txpower = None, - sf = None, cr = None, flow_control = False, id_interval = None, - allow_bluetooth = False, target_device_name = None, - target_device_address = None, id_callsign = None, st_alock = None, lt_alock = None, - ble_addr = None, ble_name = None, force_ble=False): + def __init__(self, owner, configuration): + c = configuration + name = c["name"] + allow_bluetooth = c["allow_bluetooth"] + target_device_name = c["target_device_name"] + target_device_address = c["target_device_address"] + ble_name = c["ble_name"] + ble_addr = c["ble_addr"] + force_ble = c["force_ble"] + frequency = int(c["frequency"]) if "frequency" in c else None + bandwidth = int(c["bandwidth"]) if "bandwidth" in c else None + txpower = int(c["txpower"]) if "txpower" in c else None + sf = int(c["spreadingfactor"]) if "spreadingfactor" in c else None + cr = int(c["codingrate"]) if "codingrate" in c else None + flow_control = c.as_bool("flow_control") if "flow_control" in c else False + id_interval = int(c["id_interval"]) if "id_interval" in c else None + id_callsign = c["id_callsign"] if "id_callsign" in c else None + st_alock = float(c["airtime_limit_short"]) if "airtime_limit_short" in c else None + lt_alock = float(c["airtime_limit_long"]) if "airtime_limit_long" in c else None + port = c["port"] if "port" in c else None + import importlib if RNS.vendor.platformutils.is_android(): self.on_android = True diff --git a/RNS/Interfaces/Android/SerialInterface.py b/RNS/Interfaces/Android/SerialInterface.py index 7d3d905..6d24386 100644 --- a/RNS/Interfaces/Android/SerialInterface.py +++ b/RNS/Interfaces/Android/SerialInterface.py @@ -42,6 +42,7 @@ class HDLC(): class SerialInterface(Interface): MAX_CHUNK = 32768 + DEFAULT_IFAC_SIZE = 8 owner = None port = None @@ -51,7 +52,7 @@ class SerialInterface(Interface): stopbits = None serial = None - def __init__(self, owner, name, port, speed, databits, parity, stopbits): + def __init__(self, owner, configuration): import importlib if RNS.vendor.platformutils.is_android(): self.on_android = True @@ -74,6 +75,17 @@ class SerialInterface(Interface): super().__init__() + c = configuration + name = c["name"] + 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 + + if port == None: + raise ValueError("No port specified for serial interface") + self.HW_MTU = 564 self.pyserial = serial