From 76545fec4d7157bae7722838c03cee7633503e73 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 29 Oct 2022 16:39:54 +0200 Subject: [PATCH] Added hardware error communication to UI and improved RNode cleanup on teardown --- sbapp/main.py | 3 +-- sbapp/services/sidebandservice.py | 1 + sbapp/sideband/core.py | 27 ++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index e7591ed..098d145 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -1,5 +1,4 @@ -# TODO: Reset -__debug_build__ = True +__debug_build__ = False __disable_shaders__ = True __version__ = "0.2.6" __variant__ = "beta" diff --git a/sbapp/services/sidebandservice.py b/sbapp/services/sidebandservice.py index 59dddca..fd25e0c 100644 --- a/sbapp/services/sidebandservice.py +++ b/sbapp/services/sidebandservice.py @@ -321,6 +321,7 @@ class SidebandService(): time.sleep(sleep_time) + self.sideband.cleanup() self.release_locks() SidebandService().start() diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 70c8b8b..527aa68 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -9,6 +9,8 @@ import sqlite3 import RNS.vendor.umsgpack as msgpack import RNS.Interfaces.Interface as Interface +from .res import sideband_fb_data + if RNS.vendor.platformutils.get_platform() == "android": from jnius import autoclass, cast @@ -396,7 +398,10 @@ class SidebandCore(): self.active_propagation_node = dest self.config["last_lxmf_propagation_node"] = dest self.message_router.set_outbound_propagation_node(dest) - self.owner_app.root.ids.settings_propagation_node_address.text = RNS.hexrep(dest, delimit=False) + + if not self.is_service: + self.owner_app.root.ids.settings_propagation_node_address.text = RNS.hexrep(dest, delimit=False) + RNS.log("Active propagation node set to: "+RNS.prettyhexrep(dest)) self.__save_config() except Exception as e: @@ -675,6 +680,13 @@ class SidebandCore(): try: entry = result[0] val = msgpack.unpackb(entry[1]) + if val == None: + db = sqlite3.connect(self.db_path) + dbc = db.cursor() + query = "delete from persistent where (property=:uprop);" + dbc.execute(query, {"uprop": prop.encode("utf-8")}) + db.commit() + return val except Exception as e: RNS.log("Could not unpack persistent value from database for property \""+str(prop)+"\". The contained exception was: "+str(e), RNS.LOG_ERROR) @@ -1372,6 +1384,14 @@ class SidebandCore(): 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() + except Exception as e: RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e)) self.interface_rnode = None @@ -1699,6 +1719,11 @@ class SidebandCore(): else: return "Unknown" + def cleanup(self): + if RNS.vendor.platformutils.get_platform() == "android": + if not self.reticulum.is_connected_to_shared_instance: + RNS.Transport.detach_interfaces() + rns_config = """ [reticulum] enable_transport = TRANSPORT_IS_ENABLED