mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added ability to discern telemetry changes
This commit is contained in:
parent
779cfc8662
commit
8dad802f53
@ -72,7 +72,9 @@ class SidebandCore():
|
|||||||
SERVICE_JOB_INTERVAL = 1
|
SERVICE_JOB_INTERVAL = 1
|
||||||
PERIODIC_JOBS_INTERVAL = 60
|
PERIODIC_JOBS_INTERVAL = 60
|
||||||
PERIODIC_SYNC_RETRY = 360
|
PERIODIC_SYNC_RETRY = 360
|
||||||
TELEMETRY_INTERVAL = 60
|
# TODO: Reset
|
||||||
|
# TELEMETRY_INTERVAL = 60
|
||||||
|
TELEMETRY_INTERVAL = 10
|
||||||
|
|
||||||
IF_CHANGE_ANNOUNCE_MIN_INTERVAL = 6 # In seconds
|
IF_CHANGE_ANNOUNCE_MIN_INTERVAL = 6 # In seconds
|
||||||
AUTO_ANNOUNCE_RANDOM_MIN = 90 # In minutes
|
AUTO_ANNOUNCE_RANDOM_MIN = 90 # In minutes
|
||||||
@ -101,6 +103,7 @@ class SidebandCore():
|
|||||||
self.telemeter = None
|
self.telemeter = None
|
||||||
self.telemetry_running = False
|
self.telemetry_running = False
|
||||||
self.latest_telemetry = None
|
self.latest_telemetry = None
|
||||||
|
self.telemetry_changes = 0
|
||||||
|
|
||||||
self.app_dir = plyer.storagepath.get_home_dir()+"/.config/sideband"
|
self.app_dir = plyer.storagepath.get_home_dir()+"/.config/sideband"
|
||||||
if self.app_dir.startswith("file://"):
|
if self.app_dir.startswith("file://"):
|
||||||
@ -1396,7 +1399,29 @@ class SidebandCore():
|
|||||||
self.telemeter.stop_all()
|
self.telemeter.stop_all()
|
||||||
|
|
||||||
def update_telemetry(self):
|
def update_telemetry(self):
|
||||||
self.latest_telemetry = self.get_telemetry()
|
telemetry = self.get_telemetry()
|
||||||
|
packed_telemetry = self.get_packed_telemetry()
|
||||||
|
telemetry_changed = False
|
||||||
|
|
||||||
|
if telemetry != None and packed_telemetry != None:
|
||||||
|
if self.latest_telemetry == None or len(telemetry) != len(self.latest_telemetry):
|
||||||
|
telemetry_changed = True
|
||||||
|
|
||||||
|
for sn in telemetry:
|
||||||
|
if telemetry_changed:
|
||||||
|
break
|
||||||
|
|
||||||
|
if sn != "time":
|
||||||
|
if sn in self.latest_telemetry:
|
||||||
|
if telemetry[sn] != self.latest_telemetry[sn]:
|
||||||
|
telemetry_changed = True
|
||||||
|
else:
|
||||||
|
telemetry_changed = True
|
||||||
|
|
||||||
|
if telemetry_changed:
|
||||||
|
self.telemetry_changes += 1
|
||||||
|
self.latest_telemetry = telemetry
|
||||||
|
self.latest_packed_telemetry = packed_telemetry
|
||||||
|
|
||||||
def update_telemeter_config(self):
|
def update_telemeter_config(self):
|
||||||
if self.config["telemetry_enabled"] == True:
|
if self.config["telemetry_enabled"] == True:
|
||||||
@ -1418,7 +1443,7 @@ class SidebandCore():
|
|||||||
self.update_telemeter_config()
|
self.update_telemeter_config()
|
||||||
packed = self.telemeter.packed()
|
packed = self.telemeter.packed()
|
||||||
# TODO: Remove
|
# TODO: Remove
|
||||||
RNS.log(str(packed), RNS.LOG_WARNING)
|
RNS.log("Packed telemetry: "+str(packed), RNS.LOG_WARNING)
|
||||||
return packed
|
return packed
|
||||||
|
|
||||||
def is_known(self, dest_hash):
|
def is_known(self, dest_hash):
|
||||||
@ -1636,12 +1661,13 @@ class SidebandCore():
|
|||||||
self.lxmf_announce()
|
self.lxmf_announce()
|
||||||
self.last_if_change_announce = time.time()
|
self.last_if_change_announce = time.time()
|
||||||
|
|
||||||
if self.config["telemetry_enabled"]:
|
|
||||||
self.latest_telemetry = self.run_telemetry()
|
|
||||||
|
|
||||||
self.periodic_thread = threading.Thread(target=self._periodic_jobs, daemon=True)
|
self.periodic_thread = threading.Thread(target=self._periodic_jobs, daemon=True)
|
||||||
self.periodic_thread.start()
|
self.periodic_thread.start()
|
||||||
|
|
||||||
|
if self.is_standalone or self.is_client:
|
||||||
|
if self.config["telemetry_enabled"]:
|
||||||
|
self.latest_telemetry = self.run_telemetry()
|
||||||
|
|
||||||
def __start_jobs_immediate(self):
|
def __start_jobs_immediate(self):
|
||||||
if self.log_verbose:
|
if self.log_verbose:
|
||||||
selected_level = 7
|
selected_level = 7
|
||||||
|
@ -277,8 +277,8 @@ class Barometer(Sensor):
|
|||||||
class Location(Sensor):
|
class Location(Sensor):
|
||||||
SID = Sensor.SID_LOCATION
|
SID = Sensor.SID_LOCATION
|
||||||
|
|
||||||
STALE_TIME = 60*5
|
STALE_TIME = 15
|
||||||
MIN_DISTANCE = 5
|
MIN_DISTANCE = 4
|
||||||
ACCURACY_TARGET = 250
|
ACCURACY_TARGET = 250
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user