Skip to content

Clamp direct position packets to channel precision (fixes #8640)#10383

Open
Jord-JD wants to merge 9 commits intomeshtastic:developfrom
Jord-JD:fix/8640-position-exchange-precision
Open

Clamp direct position packets to channel precision (fixes #8640)#10383
Jord-JD wants to merge 9 commits intomeshtastic:developfrom
Jord-JD:fix/8640-position-exchange-precision

Conversation

@Jord-JD
Copy link
Copy Markdown
Contributor

@Jord-JD Jord-JD commented May 3, 2026

This MR fixes #8640, where using Exchange Positions from the node list can send a full-precision position over a channel configured with reduced position precision.

The issue appears to be that direct position packets are still channel-encrypted packets with a to field, so all nodes on that channel can decode them. The existing precision truncation was happening in module processing, but direct sends do not reliably pass through that path before being transmitted.


This PR moves the position precision handling into a shared helper (src/mesh/PositionPrecision.cpp) and applies it from Router::send() after the final channel index is known and before encryption/MQTT handling.

This means any outgoing POSITION_APP packet sent on a channel is filtered according to that channel's module_settings.position_precision, including direct position exchanges and position replies. PositionModule also uses the same helper now, so the existing broadcast/reply behaviour stays consistent.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • Heltec V4
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label May 3, 2026
@Jord-JD
Copy link
Copy Markdown
Contributor Author

Jord-JD commented May 3, 2026

Still working on local testing for this, but thought I'd get it in sooner rather than later given the privacy implications of the related issue, and to allow others to test if they wish.

@Jord-JD
Copy link
Copy Markdown
Contributor Author

Jord-JD commented May 4, 2026

Tested on Heltec V4. Seems to work fine.

I used 'Exchange Position' from the Android app to another local node, and saw that the node position received was imprecise in a way that was consistent with the V4 node's channel position precision settings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a privacy/behavior gap where “direct” POSITION_APP packets (still channel-encrypted and readable by any node on that channel) could bypass per-channel position precision truncation. It centralizes position-precision enforcement and applies it in Router::send() once the final channel index is known, ensuring consistent truncation for broadcasts, replies, and direct exchanges.

Changes:

  • Add a shared PositionPrecision helper to compute per-channel precision and clamp/scrub outgoing meshtastic_Position payloads.
  • Apply position precision in Router::send() prior to encryption/MQTT handling, closing the “direct send” bypass.
  • Update PositionModule to use the shared helper and add a dedicated unit test suite for precision behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_position_precision/test_main.cpp Adds unit tests covering truncation, full precision, scrubbing, and packet re-encode behavior.
src/modules/PositionModule.cpp Replaces inline truncation logic with shared helper calls for consistent precision handling.
src/mesh/Router.cpp Enforces position precision in the final send path after channel selection, before encode/encrypt/MQTT.
src/mesh/PositionPrecision.h Declares shared helper APIs for channel precision and packet/position filtering.
src/mesh/PositionPrecision.cpp Implements shared precision selection + truncation/scrub logic and packet re-encode.

Comment thread src/mesh/PositionPrecision.cpp
Comment thread src/mesh/PositionPrecision.cpp Outdated
Comment thread src/modules/PositionModule.cpp Outdated
@Jord-JD
Copy link
Copy Markdown
Contributor Author

Jord-JD commented May 4, 2026

@thebentern Review comments addressed. Give me a shout if you need anything else changing.

@Jord-JD
Copy link
Copy Markdown
Contributor Author

Jord-JD commented May 5, 2026

I'll take a look at these check/test errors.

@Jord-JD
Copy link
Copy Markdown
Contributor Author

Jord-JD commented May 5, 2026

I think the check/test errors should now be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Exchange Positions from node list sends location with precision bits "null"

2 participants