Updated telemetry change processing method
This commit is contained in:
parent
0d38fa7ef7
commit
51523a216d
|
@ -1,6 +1,6 @@
|
||||||
__debug_build__ = False
|
__debug_build__ = False
|
||||||
__disable_shaders__ = False
|
__disable_shaders__ = False
|
||||||
__version__ = "0.9.1"
|
__version__ = "0.9.2"
|
||||||
__variant__ = "beta"
|
__variant__ = "beta"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -13,6 +13,7 @@ import RNS.Interfaces.Interface as Interface
|
||||||
|
|
||||||
import multiprocessing.connection
|
import multiprocessing.connection
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from .res import sideband_fb_data
|
from .res import sideband_fb_data
|
||||||
from .sense import Telemeter, Commands
|
from .sense import Telemeter, Commands
|
||||||
|
@ -2592,33 +2593,42 @@ class SidebandCore():
|
||||||
|
|
||||||
def update_telemetry(self):
|
def update_telemetry(self):
|
||||||
try:
|
try:
|
||||||
|
try:
|
||||||
|
latest_telemetry = deepcopy(self.latest_telemetry)
|
||||||
|
except:
|
||||||
|
latest_telemetry = None
|
||||||
|
|
||||||
telemetry = self.get_telemetry()
|
telemetry = self.get_telemetry()
|
||||||
packed_telemetry = self.get_packed_telemetry()
|
packed_telemetry = self.get_packed_telemetry()
|
||||||
telemetry_changed = False
|
telemetry_changed = False
|
||||||
|
|
||||||
if telemetry != None and packed_telemetry != None:
|
if telemetry != None and packed_telemetry != None:
|
||||||
if self.latest_telemetry == None or len(telemetry) != len(self.latest_telemetry):
|
if latest_telemetry == None or len(telemetry) != len(latest_telemetry):
|
||||||
telemetry_changed = True
|
telemetry_changed = True
|
||||||
|
|
||||||
for sn in telemetry:
|
if latest_telemetry != None:
|
||||||
if telemetry_changed:
|
|
||||||
break
|
|
||||||
|
|
||||||
if sn != "time":
|
if not telemetry_changed:
|
||||||
if sn in self.latest_telemetry:
|
for sn in telemetry:
|
||||||
if telemetry[sn] != self.latest_telemetry[sn]:
|
if telemetry_changed:
|
||||||
telemetry_changed = True
|
break
|
||||||
else:
|
|
||||||
telemetry_changed = True
|
|
||||||
|
|
||||||
if self.latest_telemetry != None:
|
if sn != "time":
|
||||||
for sn in self.latest_telemetry:
|
if sn in latest_telemetry:
|
||||||
if telemetry_changed:
|
if telemetry[sn] != latest_telemetry[sn]:
|
||||||
break
|
telemetry_changed = True
|
||||||
|
else:
|
||||||
|
telemetry_changed = True
|
||||||
|
|
||||||
if sn != "time":
|
if not telemetry_changed:
|
||||||
if not sn in telemetry:
|
for sn in latest_telemetry:
|
||||||
telemetry_changed = True
|
|
||||||
|
if telemetry_changed:
|
||||||
|
break
|
||||||
|
|
||||||
|
if sn != "time":
|
||||||
|
if not sn in telemetry:
|
||||||
|
telemetry_changed = True
|
||||||
|
|
||||||
if telemetry_changed:
|
if telemetry_changed:
|
||||||
self.telemetry_changes += 1
|
self.telemetry_changes += 1
|
||||||
|
@ -2626,6 +2636,11 @@ class SidebandCore():
|
||||||
self.latest_packed_telemetry = packed_telemetry
|
self.latest_packed_telemetry = packed_telemetry
|
||||||
self.setstate("app.flags.last_telemetry", time.time())
|
self.setstate("app.flags.last_telemetry", time.time())
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
|
# tbt = Telemeter.from_packed(packed_telemetry)
|
||||||
|
# tbts = tbt.read_all()["time"]["utc"]
|
||||||
|
# RNS.log("TELEMETRY CHANGED, TIMEBASE IS NOW "+str(tbts))
|
||||||
|
|
||||||
if self.is_client:
|
if self.is_client:
|
||||||
try:
|
try:
|
||||||
self.service_set_latest_telemetry(self.latest_telemetry, self.latest_packed_telemetry)
|
self.service_set_latest_telemetry(self.latest_telemetry, self.latest_packed_telemetry)
|
||||||
|
@ -3523,7 +3538,7 @@ class SidebandCore():
|
||||||
try:
|
try:
|
||||||
telemeter = Telemeter.from_packed(message.fields[LXMF.FIELD_TELEMETRY])
|
telemeter = Telemeter.from_packed(message.fields[LXMF.FIELD_TELEMETRY])
|
||||||
telemetry_timebase = telemeter.read_all()["time"]["utc"]
|
telemetry_timebase = telemeter.read_all()["time"]["utc"]
|
||||||
RNS.log("Setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash)+" to "+str(telemetry_timebase))
|
RNS.log("Setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash)+" to "+str(telemetry_timebase), RNS.LOG_DEBUG)
|
||||||
self.setpersistent(f"telemetry.{RNS.hexrep(message.destination_hash, delimit=False)}.last_send_success_timebase", telemetry_timebase)
|
self.setpersistent(f"telemetry.{RNS.hexrep(message.destination_hash, delimit=False)}.last_send_success_timebase", telemetry_timebase)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash), RNS.LOG_DEBUG)
|
RNS.log("Error while setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash), RNS.LOG_DEBUG)
|
||||||
|
@ -3536,10 +3551,11 @@ class SidebandCore():
|
||||||
if send_telemetry and self.latest_packed_telemetry != None:
|
if send_telemetry and self.latest_packed_telemetry != None:
|
||||||
telemeter = Telemeter.from_packed(self.latest_packed_telemetry)
|
telemeter = Telemeter.from_packed(self.latest_packed_telemetry)
|
||||||
telemetry_timebase = telemeter.read_all()["time"]["utc"]
|
telemetry_timebase = telemeter.read_all()["time"]["utc"]
|
||||||
if telemetry_timebase > (self.getpersistent(f"telemetry.{RNS.hexrep(context_dest, delimit=False)}.last_send_success_timebase") or 0):
|
last_success_tb = (self.getpersistent(f"telemetry.{RNS.hexrep(context_dest, delimit=False)}.last_send_success_timebase") or 0)
|
||||||
|
if telemetry_timebase > last_success_tb:
|
||||||
RNS.log("Embedding own telemetry in message since current telemetry is newer than latest successful timebase", RNS.LOG_DEBUG)
|
RNS.log("Embedding own telemetry in message since current telemetry is newer than latest successful timebase", RNS.LOG_DEBUG)
|
||||||
else:
|
else:
|
||||||
RNS.log("Not embedding own telemetry in message since current telemetry is not newer than latest successful timebase", RNS.LOG_DEBUG)
|
RNS.log("Not embedding own telemetry in message since current telemetry timebase ("+str(telemetry_timebase)+") is not newer than latest successful timebase ("+str(last_success_tb)+")", RNS.LOG_DEBUG)
|
||||||
send_telemetry = False
|
send_telemetry = False
|
||||||
send_appearance = False
|
send_appearance = False
|
||||||
if signal_already_sent:
|
if signal_already_sent:
|
||||||
|
|
Loading…
Reference in New Issue