Skip to content

Commit 8f8e8f1

Browse files
syn-ack-aiclaude
andcommitted
Fix position overwrite by lower-precision data
_onPositionReceive() now checks precisionBits before updating a node's position. Previously, any POSITION_APP packet would blindly overwrite the stored position, even if the incoming data had lower precision (e.g., a relayed map report with 13 bits overwriting a direct GPS fix with 32 bits). This caused nodes to show incorrect positions on the map when other mesh nodes relayed their position at reduced precision. Fixes #910 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eb964d7 commit 8f8e8f1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

meshtastic/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,21 @@ 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+
# update node DB as needed, but only if new position has
183+
# equal or better precision than what we already have.
184+
# This prevents low-precision map reports from overwriting
185+
# high-precision GPS positions in the node database.
186+
node = iface._getOrCreateByNum(asDict["from"])
187+
existing = node.get("position", {})
188+
existing_precision = existing.get("precisionBits", 0) or 0
189+
new_precision = p.get("precisionBits", 0) or 0
190+
if existing_precision == 0 or new_precision >= existing_precision:
191+
node["position"] = p
192+
else:
193+
logger.debug(
194+
f"Ignoring position update with lower precision "
195+
f"({new_precision} < {existing_precision}) for node {asDict['from']}"
196+
)
184197

185198

186199
def _onNodeInfoReceive(iface, asDict):

0 commit comments

Comments
 (0)