Skip to content

Commit 43b0993

Browse files
committed
Merge branch 'master' into 2.5
2 parents 0d26c26 + 33a13f7 commit 43b0993

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

meshtastic/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ def _onNodeInfoReceive(iface, asDict):
191191
iface.nodes[p["id"]] = n
192192
_receiveInfoUpdate(iface, asDict)
193193

194+
def _onTelemetryReceive(iface, asDict):
195+
"""Automatically update device metrics on received packets"""
196+
logging.debug(f"in _onTelemetryReceive() asDict:{asDict}")
197+
deviceMetrics = asDict.get("decoded", {}).get("telemetry", {}).get("deviceMetrics")
198+
if "from" in asDict and deviceMetrics is not None:
199+
node = iface._getOrCreateByNum(asDict["from"])
200+
newMetrics = node.get("deviceMetrics", {})
201+
newMetrics.update(deviceMetrics)
202+
logging.debug(f"updating metrics for {asDict['from']} to {newMetrics}")
203+
node["deviceMetrics"] = newMetrics
194204

195205
def _receiveInfoUpdate(iface, asDict):
196206
if "from" in asDict:
@@ -229,7 +239,7 @@ def _onAdminReceive(iface, asDict):
229239
),
230240
portnums_pb2.PortNum.ROUTING_APP: KnownProtocol("routing", mesh_pb2.Routing),
231241
portnums_pb2.PortNum.TELEMETRY_APP: KnownProtocol(
232-
"telemetry", telemetry_pb2.Telemetry
242+
"telemetry", telemetry_pb2.Telemetry, _onTelemetryReceive
233243
),
234244
portnums_pb2.PortNum.REMOTE_HARDWARE_APP: KnownProtocol(
235245
"remotehw", remote_hardware_pb2.HardwareMessage

poetry.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)