From b5bde9932280e3294b62074d40075c7071571aa0 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 1 Oct 2024 17:25:44 +0200 Subject: [PATCH] Added RNode battery info to rnstatus output --- RNS/Reticulum.py | 7 +++++++ RNS/Utilities/rnstatus.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 55e5a46..2477891 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -1319,6 +1319,13 @@ class Reticulum: if hasattr(interface, "r_channel_load_long"): ifstats["channel_load_long"] = interface.r_channel_load_long + if hasattr(interface, "r_battery_state"): + if interface.r_battery_state != 0x00: + ifstats["battery_state"] = interface.r_battery_state + + if hasattr(interface, "r_battery_percent"): + ifstats["battery_percent"] = interface.r_battery_percent + if hasattr(interface, "bitrate"): if interface.bitrate != None: ifstats["bitrate"] = interface.bitrate diff --git a/RNS/Utilities/rnstatus.py b/RNS/Utilities/rnstatus.py index 98daff5..8a8d10b 100644 --- a/RNS/Utilities/rnstatus.py +++ b/RNS/Utilities/rnstatus.py @@ -292,6 +292,13 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json= if "bitrate" in ifstat and ifstat["bitrate"] != None: print(" Rate : {ss}".format(ss=speed_str(ifstat["bitrate"]))) + if "battery_percent" in ifstat and ifstat["battery_percent"] != None: + try: + bpi = int(ifstat["battery_percent"]) + print(" Battery : {bp}%".format(bp=bpi)) + except: + pass + if "airtime_short" in ifstat and "airtime_long" in ifstat: print(" Airtime : {ats}% (15s), {atl}% (1h)".format(ats=str(ifstat["airtime_short"]),atl=str(ifstat["airtime_long"])))