Skip to content

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

Merged
thebentern merged 10 commits into
meshtastic:developfrom
Jord-JD:fix/8640-position-exchange-precision
May 15, 2026
Merged

Clamp direct position packets to channel precision (fixes #8640)#10383
thebentern merged 10 commits into
meshtastic:developfrom
Jord-JD:fix/8640-position-exchange-precision

Conversation

@Jord-JD

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

Copy link
Copy Markdown
Contributor

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

Jord-JD commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

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

Jord-JD commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 and others added 2 commits May 4, 2026 12:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Jord-JD

Jord-JD commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

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

@Jord-JD

Jord-JD commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

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

@Jord-JD

Jord-JD commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

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

@thebentern thebentern merged commit 4827498 into meshtastic:develop May 15, 2026
82 checks passed
thebentern pushed a commit that referenced this pull request May 16, 2026
)

* Fix position precision for direct sends

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Clarify zero position precision logging

* Use const channel reference for position precision

* Use C linkage for position precision test entrypoints

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Evil8it pushed a commit to Evil8it/ME4TACTNK that referenced this pull request Jun 10, 2026
…8640) (meshtastic#10383)

* Fix position precision for direct sends

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Clarify zero position precision logging

* Use const channel reference for position precision

* Use C linkage for position precision test entrypoints

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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"

3 participants