diff --git a/sbapp/main.py b/sbapp/main.py index d9cfce2..d8c6430 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -1062,6 +1062,14 @@ class SidebandApp(MDApp): self.sideband.config["connect_rnode_ifac_netname"] = self.root.ids.connectivity_rnode_ifac_netname.text self.sideband.config["connect_rnode_ifac_passphrase"] = self.root.ids.connectivity_rnode_ifac_passphrase.text + self.sideband.config["connect_serial"] = self.root.ids.connectivity_use_serial.active + self.sideband.config["connect_serial_ifac_netname"] = self.root.ids.connectivity_serial_ifac_netname.text + self.sideband.config["connect_serial_ifac_passphrase"] = self.root.ids.connectivity_serial_ifac_passphrase.text + + self.sideband.config["connect_modem"] = self.root.ids.connectivity_use_modem.active + self.sideband.config["connect_modem_ifac_netname"] = self.root.ids.connectivity_modem_ifac_netname.text + self.sideband.config["connect_modem_ifac_passphrase"] = self.root.ids.connectivity_modem_ifac_passphrase.text + con_collapse_local(collapse=not self.root.ids.connectivity_use_local.active) con_collapse_tcp(collapse=not self.root.ids.connectivity_use_tcp.active) con_collapse_i2p(collapse=not self.root.ids.connectivity_use_i2p.active) @@ -1072,6 +1080,20 @@ class SidebandApp(MDApp): self.sideband.save_configuration() + def serial_connectivity_save(sender=None, event=None): + if sender.active: + self.root.ids.connectivity_use_rnode.unbind(active=serial_connectivity_save) + self.root.ids.connectivity_use_modem.unbind(active=serial_connectivity_save) + self.root.ids.connectivity_use_serial.unbind(active=serial_connectivity_save) + self.root.ids.connectivity_use_rnode.active = False + self.root.ids.connectivity_use_modem.active = False + self.root.ids.connectivity_use_serial.active = False + sender.active = True + self.root.ids.connectivity_use_rnode.bind(active=serial_connectivity_save) + self.root.ids.connectivity_use_modem.bind(active=serial_connectivity_save) + self.root.ids.connectivity_use_serial.bind(active=serial_connectivity_save) + save_connectivity(sender, event) + def focus_save(sender=None, event=None): if not sender.focus: save_connectivity(sender, event) @@ -1116,11 +1138,16 @@ class SidebandApp(MDApp): self.root.ids.connectivity_use_bluetooth.active = False con_collapse_bluetooth(collapse=not self.root.ids.connectivity_use_bluetooth.active) - self.root.ids.connectivity_use_modem.active = False - con_collapse_modem(collapse=not self.root.ids.connectivity_use_modem.active) - self.root.ids.connectivity_use_serial.active = False + self.root.ids.connectivity_use_modem.active = self.sideband.config["connect_modem"] + con_collapse_modem(collapse=not self.root.ids.connectivity_use_modem.active) + self.root.ids.connectivity_modem_ifac_netname.text = self.sideband.config["connect_modem_ifac_netname"] + self.root.ids.connectivity_modem_ifac_passphrase.text = self.sideband.config["connect_modem_ifac_passphrase"] + + self.root.ids.connectivity_use_serial.active = self.sideband.config["connect_serial"] con_collapse_serial(collapse=not self.root.ids.connectivity_use_serial.active) + self.root.ids.connectivity_serial_ifac_netname.text = self.sideband.config["connect_serial_ifac_netname"] + self.root.ids.connectivity_serial_ifac_passphrase.text = self.sideband.config["connect_serial_ifac_passphrase"] self.root.ids.connectivity_use_local.bind(active=save_connectivity) self.root.ids.connectivity_local_groupid.bind(on_text_validate=save_connectivity) @@ -1135,13 +1162,14 @@ class SidebandApp(MDApp): self.root.ids.connectivity_i2p_b32.bind(on_text_validate=save_connectivity) self.root.ids.connectivity_i2p_ifac_netname.bind(on_text_validate=save_connectivity) self.root.ids.connectivity_i2p_ifac_passphrase.bind(on_text_validate=save_connectivity) - self.root.ids.connectivity_use_rnode.bind(active=save_connectivity) self.root.ids.connectivity_rnode_ifac_netname.bind(on_text_validate=save_connectivity) self.root.ids.connectivity_rnode_ifac_passphrase.bind(on_text_validate=save_connectivity) - self.root.ids.connectivity_use_modem.bind(active=save_connectivity) - self.root.ids.connectivity_use_serial.bind(active=save_connectivity) self.root.ids.connectivity_use_bluetooth.bind(active=save_connectivity) + self.root.ids.connectivity_use_rnode.bind(active=serial_connectivity_save) + self.root.ids.connectivity_use_modem.bind(active=serial_connectivity_save) + self.root.ids.connectivity_use_serial.bind(active=serial_connectivity_save) + self.root.ids.connectivity_local_groupid.bind(focus=focus_save) self.root.ids.connectivity_local_ifac_netname.bind(focus=focus_save) self.root.ids.connectivity_local_ifac_passphrase.bind(focus=focus_save) @@ -1155,6 +1183,12 @@ class SidebandApp(MDApp): self.root.ids.connectivity_rnode_ifac_netname.bind(focus=focus_save) self.root.ids.connectivity_rnode_ifac_passphrase.bind(focus=focus_save) + self.root.ids.connectivity_modem_ifac_netname.bind(focus=focus_save) + self.root.ids.connectivity_modem_ifac_passphrase.bind(focus=focus_save) + + self.root.ids.connectivity_serial_ifac_netname.bind(focus=focus_save) + self.root.ids.connectivity_serial_ifac_passphrase.bind(focus=focus_save) + else: info = "" @@ -1205,8 +1239,9 @@ class SidebandApp(MDApp): con_collapse_local(collapse=not self.root.ids.connectivity_use_local.active) self.sideband.save_configuration() - if RNS.vendor.platformutils.get_platform() == "android": - if not self.sideband.getpersistent("service.is_controlling_connectivity"): + # TODO: Reset + if True or RNS.vendor.platformutils.get_platform() == "android": + if False and not self.sideband.getpersistent("service.is_controlling_connectivity"): info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n" info += "To configure hardware parameters, edit the relevant configuration file for the instance." self.root.ids.hardware_info.text = info diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 62ca587..980b858 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -193,6 +193,12 @@ class SidebandCore(): self.config["connect_rnode"] = False self.config["connect_rnode_ifac_netname"] = "" self.config["connect_rnode_ifac_passphrase"] = "" + self.config["connect_serial"] = False + self.config["connect_serial_ifac_netname"] = "" + self.config["connect_serial_ifac_passphrase"] = "" + self.config["connect_modem"] = False + self.config["connect_modem_ifac_netname"] = "" + self.config["connect_modem_ifac_passphrase"] = "" # Hardware self.config["hw_rnode_frequency"] = None self.config["hw_rnode_modulation"] = "LoRa" @@ -249,7 +255,18 @@ class SidebandCore(): self.config["connect_rnode_ifac_netname"] = "" if not "connect_rnode_ifac_passphrase" in self.config: self.config["connect_rnode_ifac_passphrase"] = "" - + if not "connect_serial" in self.config: + self.config["connect_serial"] = False + if not "connect_serial_ifac_netname" in self.config: + self.config["connect_serial_ifac_netname"] = "" + if not "connect_serial_ifac_passphrase" in self.config: + self.config["connect_serial_ifac_passphrase"] = "" + if not "connect_modem" in self.config: + self.config["connect_modem"] = False + if not "connect_modem_ifac_netname" in self.config: + self.config["connect_modem_ifac_netname"] = "" + if not "connect_modem_ifac_passphrase" in self.config: + self.config["connect_modem_ifac_passphrase"] = "" if not "hw_rnode_frequency" in self.config: self.config["hw_rnode_frequency"] = None if not "hw_rnode_modulation" in self.config: diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py index 623c62a..0119e4d 100644 --- a/sbapp/ui/layouts.py +++ b/sbapp/ui/layouts.py @@ -422,13 +422,13 @@ MDNavigationLayout: id: connectivity_modem_label text: "Connect via Radio Modem" font_style: "H6" - disabled: True + disabled: False MDSwitch: id: connectivity_use_modem active: False pos_hint: {"center_y": 0.3} - disabled: True + disabled: False MDBoxLayout: id: connectivity_modem_fields @@ -460,13 +460,13 @@ MDNavigationLayout: id: connectivity_serial_label text: "Connect via Serial Port" font_style: "H6" - disabled: True + disabled: False MDSwitch: id: connectivity_use_serial active: False pos_hint: {"center_y": 0.3} - disabled: True + disabled: False MDBoxLayout: id: connectivity_serial_fields