mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-22 03:40:18 +00:00
Internal interface config handling for RNodeMultiInterface
This commit is contained in:
parent
bf633bba5d
commit
996161e2f4
@ -163,6 +163,7 @@ class KISS():
|
||||
|
||||
class RNodeMultiInterface(Interface):
|
||||
MAX_CHUNK = 32768
|
||||
DEFAULT_IFAC_SIZE = 8
|
||||
|
||||
CALLSIGN_MAX_LEN = 32
|
||||
|
||||
@ -173,7 +174,7 @@ class RNodeMultiInterface(Interface):
|
||||
|
||||
MAX_SUBINTERFACES = 11
|
||||
|
||||
def __init__(self, owner, name, port, subint_config, id_interval = None, id_callsign = None):
|
||||
def __init__(self, owner, configuration):
|
||||
if RNS.vendor.platformutils.is_android():
|
||||
raise SystemError("Invalid interface type. The Android-specific RNode interface must be used on Android")
|
||||
|
||||
@ -187,6 +188,77 @@ class RNodeMultiInterface(Interface):
|
||||
|
||||
super().__init__()
|
||||
|
||||
c = configuration
|
||||
name = c["name"]
|
||||
|
||||
count = 0
|
||||
enabled_count = 0
|
||||
|
||||
# Count how many interfaces are in the file
|
||||
for subinterface in c:
|
||||
# if the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
count += 1
|
||||
|
||||
# Count how many interfaces are enabled to allow for appropriate matrix sizing
|
||||
for subinterface in c:
|
||||
# if the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
subinterface_config = self.config["interfaces"][name][subinterface]
|
||||
if (("interface_enabled" in subinterface_config) and subinterface_config.as_bool("interface_enabled") == True) or (("enabled" in c) and c.as_bool("enabled") == True):
|
||||
enabled_count += 1
|
||||
|
||||
# Create an array with a row for each subinterface
|
||||
subint_config = [[0 for x in range(11)] for y in range(enabled_count)]
|
||||
subint_index = 0
|
||||
|
||||
for subinterface in c:
|
||||
# If the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
subinterface_config = self.config["interfaces"][name][subinterface]
|
||||
if (("interface_enabled" in subinterface_config) and subinterface_config.as_bool("interface_enabled") == True) or (("enabled" in c) and c.as_bool("enabled") == True):
|
||||
subint_config[subint_index][0] = subinterface
|
||||
|
||||
subint_vport = subinterface_config["vport"] if "vport" in subinterface_config else None
|
||||
subint_config[subint_index][1] = subint_vport
|
||||
|
||||
frequency = int(subinterface_config["frequency"]) if "frequency" in subinterface_config else None
|
||||
subint_config[subint_index][2] = frequency
|
||||
bandwidth = int(subinterface_config["bandwidth"]) if "bandwidth" in subinterface_config else None
|
||||
subint_config[subint_index][3] = bandwidth
|
||||
txpower = int(subinterface_config["txpower"]) if "txpower" in subinterface_config else None
|
||||
subint_config[subint_index][4] = txpower
|
||||
spreadingfactor = int(subinterface_config["spreadingfactor"]) if "spreadingfactor" in subinterface_config else None
|
||||
subint_config[subint_index][5] = spreadingfactor
|
||||
codingrate = int(subinterface_config["codingrate"]) if "codingrate" in subinterface_config else None
|
||||
subint_config[subint_index][6] = codingrate
|
||||
flow_control = subinterface_config.as_bool("flow_control") if "flow_control" in subinterface_config else False
|
||||
subint_config[subint_index][7] = flow_control
|
||||
st_alock = float(subinterface_config["airtime_limit_short"]) if "airtime_limit_short" in subinterface_config else None
|
||||
subint_config[subint_index][8] = st_alock
|
||||
lt_alock = float(subinterface_config["airtime_limit_long"]) if "airtime_limit_long" in subinterface_config else None
|
||||
subint_config[subint_index][9] = lt_alock
|
||||
|
||||
if "outgoing" in subinterface_config and subinterface_config.as_bool("outgoing") == False:
|
||||
subint_config[subint_index][10] = False
|
||||
else:
|
||||
subint_config[subint_index][10] = True
|
||||
subint_index += 1
|
||||
|
||||
# if no subinterfaces are defined
|
||||
if count == 0:
|
||||
raise ValueError("No subinterfaces configured for "+name)
|
||||
# if no subinterfaces are enabled
|
||||
elif enabled_count == 0:
|
||||
raise ValueError("No subinterfaces enabled for "+name)
|
||||
|
||||
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
|
||||
port = c["port"] if "port" in c else None
|
||||
|
||||
if port == None:
|
||||
raise ValueError("No port specified for "+name)
|
||||
|
||||
self.HW_MTU = 508
|
||||
|
||||
self.clients = 0
|
||||
|
@ -635,96 +635,8 @@ class Reticulum:
|
||||
interface_post_init(interface)
|
||||
|
||||
if c["type"] == "RNodeMultiInterface":
|
||||
count = 0
|
||||
enabled_count = 0
|
||||
|
||||
# Count how many interfaces are in the file
|
||||
for subinterface in c:
|
||||
# if the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
count += 1
|
||||
|
||||
# Count how many interfaces are enabled to allow for appropriate matrix sizing
|
||||
for subinterface in c:
|
||||
# if the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
subinterface_config = self.config["interfaces"][name][subinterface]
|
||||
if (("interface_enabled" in subinterface_config) and subinterface_config.as_bool("interface_enabled") == True) or (("enabled" in c) and c.as_bool("enabled") == True):
|
||||
enabled_count += 1
|
||||
|
||||
# Create an array with a row for each subinterface
|
||||
subint_config = [[0 for x in range(11)] for y in range(enabled_count)]
|
||||
subint_index = 0
|
||||
|
||||
for subinterface in c:
|
||||
# If the retrieved entry is not a string, it must be a dictionary, which is what we want
|
||||
if not isinstance(c[subinterface], str):
|
||||
subinterface_config = self.config["interfaces"][name][subinterface]
|
||||
if (("interface_enabled" in subinterface_config) and subinterface_config.as_bool("interface_enabled") == True) or (("enabled" in c) and c.as_bool("enabled") == True):
|
||||
subint_config[subint_index][0] = subinterface
|
||||
|
||||
subint_vport = subinterface_config["vport"] if "vport" in subinterface_config else None
|
||||
subint_config[subint_index][1] = subint_vport
|
||||
|
||||
frequency = int(subinterface_config["frequency"]) if "frequency" in subinterface_config else None
|
||||
subint_config[subint_index][2] = frequency
|
||||
bandwidth = int(subinterface_config["bandwidth"]) if "bandwidth" in subinterface_config else None
|
||||
subint_config[subint_index][3] = bandwidth
|
||||
txpower = int(subinterface_config["txpower"]) if "txpower" in subinterface_config else None
|
||||
subint_config[subint_index][4] = txpower
|
||||
spreadingfactor = int(subinterface_config["spreadingfactor"]) if "spreadingfactor" in subinterface_config else None
|
||||
subint_config[subint_index][5] = spreadingfactor
|
||||
codingrate = int(subinterface_config["codingrate"]) if "codingrate" in subinterface_config else None
|
||||
subint_config[subint_index][6] = codingrate
|
||||
flow_control = subinterface_config.as_bool("flow_control") if "flow_control" in subinterface_config else False
|
||||
subint_config[subint_index][7] = flow_control
|
||||
st_alock = float(subinterface_config["airtime_limit_short"]) if "airtime_limit_short" in subinterface_config else None
|
||||
subint_config[subint_index][8] = st_alock
|
||||
lt_alock = float(subinterface_config["airtime_limit_long"]) if "airtime_limit_long" in subinterface_config else None
|
||||
subint_config[subint_index][9] = lt_alock
|
||||
|
||||
if "outgoing" in subinterface_config and subinterface_config.as_bool("outgoing") == False:
|
||||
subint_config[subint_index][10] = False
|
||||
else:
|
||||
subint_config[subint_index][10] = True
|
||||
subint_index += 1
|
||||
|
||||
# if no subinterfaces are defined
|
||||
if count == 0:
|
||||
raise ValueError("No subinterfaces configured for "+name)
|
||||
# if no subinterfaces are enabled
|
||||
elif enabled_count == 0:
|
||||
raise ValueError("No subinterfaces enabled for "+name)
|
||||
|
||||
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
|
||||
port = c["port"] if "port" in c else None
|
||||
|
||||
if port == None:
|
||||
raise ValueError("No port specified for "+name)
|
||||
|
||||
interface = RNodeMultiInterface.RNodeMultiInterface(
|
||||
RNS.Transport,
|
||||
name,
|
||||
port,
|
||||
subint_config,
|
||||
id_interval = id_interval,
|
||||
id_callsign = id_callsign
|
||||
)
|
||||
|
||||
interface.IN = False
|
||||
interface.OUT = False
|
||||
|
||||
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 = RNodeMultiInterface.RNodeMultiInterface(RNS.Transport, interface_config)
|
||||
interface_post_init(interface)
|
||||
|
||||
if interface != None:
|
||||
interface.announce_rate_target = announce_rate_target
|
||||
|
@ -493,89 +493,89 @@ Multi interface can be used to configure sub-interfaces individually.
|
||||
# id_interval = 600
|
||||
|
||||
# A subinterface
|
||||
[[[HIGHDATARATE]]]
|
||||
# Subinterfaces can be enabled and disabled in of themselves
|
||||
interface_enabled = True
|
||||
[[[High Datarate]]]
|
||||
# Subinterfaces can be enabled and disabled in of themselves
|
||||
interface_enabled = True
|
||||
|
||||
# Set frequency to 2.4GHz
|
||||
frequency = 2400000000
|
||||
# Set frequency to 2.4GHz
|
||||
frequency = 2400000000
|
||||
|
||||
# Set LoRa bandwidth to 1625 KHz
|
||||
bandwidth = 1625000
|
||||
# Set LoRa bandwidth to 1625 KHz
|
||||
bandwidth = 1625000
|
||||
|
||||
# Set TX power to 0 dBm (0.12 mW)
|
||||
txpower = 0
|
||||
# Set TX power to 0 dBm (0.12 mW)
|
||||
txpower = 0
|
||||
|
||||
# The virtual port, only the manufacturer
|
||||
# or the person who wrote the board config
|
||||
# can tell you what it will be for which
|
||||
# physical hardware interface
|
||||
vport = 1
|
||||
# The virtual port, only the manufacturer
|
||||
# or the person who wrote the board config
|
||||
# can tell you what it will be for which
|
||||
# physical hardware interface
|
||||
vport = 1
|
||||
|
||||
# Select spreading factor 5. Valid
|
||||
# range is 5 through 12, with 5
|
||||
# being the fastest and 12 having
|
||||
# the longest range.
|
||||
spreadingfactor = 5
|
||||
# Select spreading factor 5. Valid
|
||||
# range is 5 through 12, with 5
|
||||
# being the fastest and 12 having
|
||||
# the longest range.
|
||||
spreadingfactor = 5
|
||||
|
||||
# Select coding rate 5. Valid range
|
||||
# is 5 throough 8, with 5 being the
|
||||
# fastest, and 8 the longest range.
|
||||
codingrate = 5
|
||||
# Select coding rate 5. Valid range
|
||||
# is 5 throough 8, with 5 being the
|
||||
# fastest, and 8 the longest range.
|
||||
codingrate = 5
|
||||
|
||||
# It is possible to limit the airtime
|
||||
# utilisation of an RNode by using the
|
||||
# following two configuration options.
|
||||
# The short-term limit is applied in a
|
||||
# window of approximately 15 seconds,
|
||||
# and the long-term limit is enforced
|
||||
# over a rolling 60 minute window. Both
|
||||
# options are specified in percent.
|
||||
# It is possible to limit the airtime
|
||||
# utilisation of an RNode by using the
|
||||
# following two configuration options.
|
||||
# The short-term limit is applied in a
|
||||
# window of approximately 15 seconds,
|
||||
# and the long-term limit is enforced
|
||||
# over a rolling 60 minute window. Both
|
||||
# options are specified in percent.
|
||||
|
||||
# airtime_limit_long = 100
|
||||
# airtime_limit_short = 100
|
||||
# airtime_limit_long = 100
|
||||
# airtime_limit_short = 100
|
||||
|
||||
[[[LOWDATARATE]]]
|
||||
# Subinterfaces can be enabled and disabled in of themselves
|
||||
interface_enabled = True
|
||||
[[[Low Datarate]]]
|
||||
# Subinterfaces can be enabled and disabled in of themselves
|
||||
interface_enabled = True
|
||||
|
||||
# Set frequency to 865.6 MHz
|
||||
frequency = 865600000
|
||||
# Set frequency to 865.6 MHz
|
||||
frequency = 865600000
|
||||
|
||||
# The virtual port, only the manufacturer
|
||||
# or the person who wrote the board config
|
||||
# can tell you what it will be for which
|
||||
# physical hardware interface
|
||||
vport = 0
|
||||
# The virtual port, only the manufacturer
|
||||
# or the person who wrote the board config
|
||||
# can tell you what it will be for which
|
||||
# physical hardware interface
|
||||
vport = 0
|
||||
|
||||
# Set LoRa bandwidth to 125 KHz
|
||||
bandwidth = 125000
|
||||
# Set LoRa bandwidth to 125 KHz
|
||||
bandwidth = 125000
|
||||
|
||||
# Set TX power to 0 dBm (0.12 mW)
|
||||
txpower = 0
|
||||
# Set TX power to 0 dBm (0.12 mW)
|
||||
txpower = 0
|
||||
|
||||
# Select spreading factor 7. Valid
|
||||
# range is 5 through 12, with 5
|
||||
# being the fastest and 12 having
|
||||
# the longest range.
|
||||
spreadingfactor = 7
|
||||
# Select spreading factor 7. Valid
|
||||
# range is 5 through 12, with 5
|
||||
# being the fastest and 12 having
|
||||
# the longest range.
|
||||
spreadingfactor = 7
|
||||
|
||||
# Select coding rate 5. Valid range
|
||||
# is 5 throough 8, with 5 being the
|
||||
# fastest, and 8 the longest range.
|
||||
codingrate = 5
|
||||
# Select coding rate 5. Valid range
|
||||
# is 5 throough 8, with 5 being the
|
||||
# fastest, and 8 the longest range.
|
||||
codingrate = 5
|
||||
|
||||
# It is possible to limit the airtime
|
||||
# utilisation of an RNode by using the
|
||||
# following two configuration options.
|
||||
# The short-term limit is applied in a
|
||||
# window of approximately 15 seconds,
|
||||
# and the long-term limit is enforced
|
||||
# over a rolling 60 minute window. Both
|
||||
# options are specified in percent.
|
||||
# It is possible to limit the airtime
|
||||
# utilisation of an RNode by using the
|
||||
# following two configuration options.
|
||||
# The short-term limit is applied in a
|
||||
# window of approximately 15 seconds,
|
||||
# and the long-term limit is enforced
|
||||
# over a rolling 60 minute window. Both
|
||||
# options are specified in percent.
|
||||
|
||||
# airtime_limit_long = 100
|
||||
# airtime_limit_short = 100
|
||||
# airtime_limit_long = 100
|
||||
# airtime_limit_short = 100
|
||||
|
||||
.. _interfaces-serial:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user