mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 05:30:17 +00:00
Add RNodeMultiInterface
This commit is contained in:
parent
60e6b712d2
commit
5feb833573
1157
RNS/Interfaces/RNodeMultiInterface.py
Normal file
1157
RNS/Interfaces/RNodeMultiInterface.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -929,6 +929,95 @@ class Reticulum:
|
||||
else:
|
||||
interface.ifac_size = 8
|
||||
|
||||
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(10)] 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
|
||||
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
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
|
||||
if interface != None:
|
||||
interface.announce_rate_target = announce_rate_target
|
||||
interface.announce_rate_grace = announce_rate_grace
|
||||
|
Loading…
Reference in New Issue
Block a user