From 18b952e612d4e3c258c332e46ebcbe2072d7bc1d Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 13 Sep 2023 20:07:07 +0200 Subject: [PATCH] Added airtime config options, improved periodic data persist --- RNS/Reticulum.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index e0950c9..44a2e2b 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -133,6 +133,7 @@ class Reticulum: JOB_INTERVAL = 5*60 CLEAN_INTERVAL = 15*60 PERSIST_INTERVAL = 60*60*12 + GRACIOUS_PERSIST_INTERVAL = 60*5 router = None config = None @@ -288,7 +289,6 @@ class Reticulum: if now > self.last_data_persist+Reticulum.PERSIST_INTERVAL: self.__persist_data() - self.last_data_persist = time.time() time.sleep(Reticulum.JOB_INTERVAL) @@ -835,6 +835,8 @@ class Reticulum: flow_control = c.as_bool("flow_control") if "flow_control" in c else False 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 + st_alock = float(c["airtime_limit_short"]) if "airtime_limit_short" in c else None + lt_alock = float(c["airtime_limit_long"]) if "airtime_limit_long" in c else None port = c["port"] if "port" in c else None @@ -852,7 +854,9 @@ class Reticulum: cr = codingrate, flow_control = flow_control, id_interval = id_interval, - id_callsign = id_callsign + id_callsign = id_callsign, + st_alock = st_alock, + lt_alock = lt_alock ) if "outgoing" in c and c.as_bool("outgoing") == False: @@ -960,11 +964,13 @@ class Reticulum: RNS.Transport.interfaces.append(interface) def _should_persist_data(self): - self.__persist_data() + if time.time() > self.last_data_persist+Reticulum.GRACIOUS_PERSIST_INTERVAL: + self.__persist_data() def __persist_data(self): RNS.Transport.persist_data() RNS.Identity.persist_data() + self.last_data_persist = time.time() def __clean_caches(self): RNS.log("Cleaning resource and packet caches...", RNS.LOG_EXTREME) @@ -1089,6 +1095,18 @@ class Reticulum: else: ifstats["tunnelstate"] = None + if hasattr(interface, "r_airtime_short"): + ifstats["airtime_short"] = interface.r_airtime_short + + if hasattr(interface, "r_airtime_long"): + ifstats["airtime_long"] = interface.r_airtime_long + + if hasattr(interface, "r_channel_load_short"): + ifstats["channel_load_short"] = interface.r_channel_load_short + + if hasattr(interface, "r_channel_load_long"): + ifstats["channel_load_long"] = interface.r_channel_load_long + if hasattr(interface, "bitrate"): if interface.bitrate != None: ifstats["bitrate"] = interface.bitrate