mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Improved RNode bluetooth hotplug
This commit is contained in:
parent
990cfb024a
commit
c3b9172233
@ -1578,83 +1578,81 @@ class SidebandCore():
|
||||
# TODO: Add more intelligent selection here
|
||||
target_device = self.owner_app.usb_devices[0]
|
||||
|
||||
if target_device or self.config["hw_rnode_bluetooth"]:
|
||||
if target_device != None:
|
||||
target_port = target_device["port"]
|
||||
else:
|
||||
target_port = None
|
||||
# if target_device or self.config["hw_rnode_bluetooth"]:
|
||||
if target_device != None:
|
||||
target_port = target_device["port"]
|
||||
else:
|
||||
target_port = None
|
||||
|
||||
bt_device_name = None
|
||||
rnode_allow_bluetooth = False
|
||||
if self.getpersistent("permissions.bluetooth"):
|
||||
if self.config["hw_rnode_bluetooth"]:
|
||||
RNS.log("Allowing RNode bluetooth", RNS.LOG_DEBUG)
|
||||
rnode_allow_bluetooth = True
|
||||
if self.config["hw_rnode_bt_device"] != None:
|
||||
bt_device_name = self.config["hw_rnode_bt_device"]
|
||||
|
||||
bt_device_name = None
|
||||
rnode_allow_bluetooth = False
|
||||
if self.getpersistent("permissions.bluetooth"):
|
||||
if self.config["hw_rnode_bluetooth"]:
|
||||
RNS.log("Allowing RNode bluetooth", RNS.LOG_DEBUG)
|
||||
rnode_allow_bluetooth = True
|
||||
if self.config["hw_rnode_bt_device"] != None:
|
||||
bt_device_name = self.config["hw_rnode_bt_device"]
|
||||
|
||||
else:
|
||||
RNS.log("Disallowing RNode bluetooth since config is disabled", RNS.LOG_DEBUG)
|
||||
rnode_allow_bluetooth = False
|
||||
else:
|
||||
RNS.log("Disallowing RNode bluetooth due to missing permission", RNS.LOG_DEBUG)
|
||||
RNS.log("Disallowing RNode bluetooth since config is disabled", RNS.LOG_DEBUG)
|
||||
rnode_allow_bluetooth = False
|
||||
else:
|
||||
RNS.log("Disallowing RNode bluetooth due to missing permission", RNS.LOG_DEBUG)
|
||||
rnode_allow_bluetooth = False
|
||||
|
||||
if self.config["connect_rnode_ifac_netname"] == "":
|
||||
ifac_netname = None
|
||||
else:
|
||||
ifac_netname = self.config["connect_rnode_ifac_netname"]
|
||||
|
||||
if self.config["connect_rnode_ifac_passphrase"] == "":
|
||||
ifac_netkey = None
|
||||
else:
|
||||
ifac_netkey = self.config["connect_rnode_ifac_passphrase"]
|
||||
|
||||
if self.config["connect_rnode_ifac_netname"] == "":
|
||||
ifac_netname = None
|
||||
else:
|
||||
ifac_netname = self.config["connect_rnode_ifac_netname"]
|
||||
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(
|
||||
RNS.Transport,
|
||||
"RNodeInterface",
|
||||
target_port,
|
||||
frequency = self.config["hw_rnode_frequency"],
|
||||
bandwidth = self.config["hw_rnode_bandwidth"],
|
||||
txpower = self.config["hw_rnode_tx_power"],
|
||||
sf = self.config["hw_rnode_spreading_factor"],
|
||||
cr = self.config["hw_rnode_coding_rate"],
|
||||
flow_control = None,
|
||||
id_interval = self.config["hw_rnode_beaconinterval"],
|
||||
id_callsign = self.config["hw_rnode_beacondata"],
|
||||
allow_bluetooth = rnode_allow_bluetooth,
|
||||
target_device_name = bt_device_name,
|
||||
)
|
||||
|
||||
if self.config["connect_rnode_ifac_passphrase"] == "":
|
||||
ifac_netkey = None
|
||||
else:
|
||||
ifac_netkey = self.config["connect_rnode_ifac_passphrase"]
|
||||
rnodeinterface.OUT = True
|
||||
|
||||
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(
|
||||
RNS.Transport,
|
||||
"RNodeInterface",
|
||||
target_port,
|
||||
frequency = self.config["hw_rnode_frequency"],
|
||||
bandwidth = self.config["hw_rnode_bandwidth"],
|
||||
txpower = self.config["hw_rnode_tx_power"],
|
||||
sf = self.config["hw_rnode_spreading_factor"],
|
||||
cr = self.config["hw_rnode_coding_rate"],
|
||||
flow_control = None,
|
||||
id_interval = self.config["hw_rnode_beaconinterval"],
|
||||
id_callsign = self.config["hw_rnode_beacondata"],
|
||||
allow_bluetooth = rnode_allow_bluetooth,
|
||||
target_device_name = bt_device_name,
|
||||
)
|
||||
if RNS.Reticulum.transport_enabled():
|
||||
if_mode = Interface.Interface.MODE_FULL
|
||||
if self.config["connect_ifmode_rnode"] == "gateway":
|
||||
if_mode = Interface.Interface.MODE_GATEWAY
|
||||
elif self.config["connect_ifmode_rnode"] == "access point":
|
||||
if_mode = Interface.Interface.MODE_ACCESS_POINT
|
||||
elif self.config["connect_ifmode_rnode"] == "roaming":
|
||||
if_mode = Interface.Interface.MODE_ROAMING
|
||||
elif self.config["connect_ifmode_rnode"] == "boundary":
|
||||
if_mode = Interface.Interface.MODE_BOUNDARY
|
||||
else:
|
||||
if_mode = None
|
||||
|
||||
self.reticulum._add_interface(rnodeinterface, mode = if_mode, ifac_netname = ifac_netname, ifac_netkey = ifac_netkey)
|
||||
self.interface_rnode = rnodeinterface
|
||||
|
||||
rnodeinterface.OUT = True
|
||||
if rnodeinterface != None:
|
||||
if len(rnodeinterface.hw_errors) > 0:
|
||||
self.setpersistent("startup.errors.rnode", rnodeinterface.hw_errors[0])
|
||||
|
||||
if RNS.Reticulum.transport_enabled():
|
||||
if_mode = Interface.Interface.MODE_FULL
|
||||
if self.config["connect_ifmode_rnode"] == "gateway":
|
||||
if_mode = Interface.Interface.MODE_GATEWAY
|
||||
elif self.config["connect_ifmode_rnode"] == "access point":
|
||||
if_mode = Interface.Interface.MODE_ACCESS_POINT
|
||||
elif self.config["connect_ifmode_rnode"] == "roaming":
|
||||
if_mode = Interface.Interface.MODE_ROAMING
|
||||
elif self.config["connect_ifmode_rnode"] == "boundary":
|
||||
if_mode = Interface.Interface.MODE_BOUNDARY
|
||||
else:
|
||||
if_mode = None
|
||||
|
||||
self.reticulum._add_interface(rnodeinterface, mode = if_mode, ifac_netname = ifac_netname, ifac_netkey = ifac_netkey)
|
||||
self.interface_rnode = rnodeinterface
|
||||
|
||||
if rnodeinterface != None:
|
||||
if len(rnodeinterface.hw_errors) > 0:
|
||||
self.setpersistent("startup.errors.rnode", rnodeinterface.hw_errors[0])
|
||||
|
||||
if self.interface_rnode.online:
|
||||
self.interface_rnode.display_image(sideband_fb_data)
|
||||
self.interface_rnode.enable_external_framebuffer()
|
||||
else:
|
||||
self.interface_rnode.last_imagedata = sideband_fb_data
|
||||
if self.interface_rnode.online:
|
||||
self.interface_rnode.display_image(sideband_fb_data)
|
||||
self.interface_rnode.enable_external_framebuffer()
|
||||
else:
|
||||
self.interface_rnode.last_imagedata = sideband_fb_data
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user