Skip to content

Commit 8a842ed

Browse files
syn-ack-aiclaude
andcommitted
Fix local node position overwrite by low-precision echoes
When other nodes relay our position via map reports, they send it at reduced precision (e.g., 13 bits). _onPositionReceive() was blindly overwriting our locally-stored high-precision GPS position (32 bits) with these degraded echoes. The fix only protects the local node's position — since we have the GPS internally, any lower-precision update is always an echo from the mesh, never fresh data. Remote node positions are still updated normally, as any position they broadcast reflects their current state. Fixes #910 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eb964d7 commit 8a842ed

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

meshtastic/__init__.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,30 @@ def _onPositionReceive(iface, asDict):
179179
logger.debug(f"p:{p}")
180180
p = iface._fixupPosition(p)
181181
logger.debug(f"after fixup p:{p}")
182-
# update node DB as needed
183-
iface._getOrCreateByNum(asDict["from"])["position"] = p
182+
# For the local node, only accept position updates with equal
183+
# or better precision. The local GPS is authoritative, and
184+
# low-precision echoes from the mesh (e.g., map reports relayed
185+
# by other nodes) should not overwrite it.
186+
# For remote nodes, always accept the latest position since
187+
# any update from them reflects their current state.
188+
node = iface._getOrCreateByNum(asDict["from"])
189+
is_local_node = (
190+
iface.myInfo is not None
191+
and asDict["from"] == iface.myInfo.my_node_num
192+
)
193+
if is_local_node:
194+
existing = node.get("position", {})
195+
existing_precision = existing.get("precisionBits", 0) or 0
196+
new_precision = p.get("precisionBits", 0) or 0
197+
if existing_precision == 0 or new_precision >= existing_precision:
198+
node["position"] = p
199+
else:
200+
logger.debug(
201+
f"Ignoring low-precision position echo for local node "
202+
f"({new_precision} < {existing_precision})"
203+
)
204+
else:
205+
node["position"] = p
184206

185207

186208
def _onNodeInfoReceive(iface, asDict):

0 commit comments

Comments
 (0)