Skip to content

Request a current GPS position for the map - #11403

Open
RCGV1 wants to merge 7 commits into
meshtastic:developfrom
RCGV1:codex/gps-position-update
Open

Request a current GPS position for the map#11403
RCGV1 wants to merge 7 commits into
meshtastic:developfrom
RCGV1:codex/gps-position-update

Conversation

@RCGV1

@RCGV1 RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

Adds authenticated AdminMessage handling for an on-demand GPS sample and forwards the resulting local position to the connected client without broadcasting it over the mesh. Requests are coalesced for 10 seconds.

Depends on protobuf PR #1032.

Testing

  • trunk fmt

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds on-demand GPS position requests. Admin messages trigger GPS sampling, GPS throttles requests, and valid requested positions are forwarded to the phone. Tests cover serialization and unavailable-GPS handling.

Changes

GPS position request flow

Layer / File(s) Summary
GPS request and forwarding state
src/gps/GPS.cpp, src/gps/GPS.h, src/modules/PositionModule.h
GPS adds requestPositionUpdate(), throttling, receiver wake-up, phone forwarding, and timeout cleanup. sendOurPositionToPhone() is publicly available for forwarding.
Admin request handling
protobufs, src/modules/AdminModule.cpp
The admin handler processes request_position_update and returns BAD_REQUEST when GPS is unavailable or the request fails.
Admin request validation
test/test_admin_radio/test_main.cpp
Tests verify request serialization, test registration, and unavailable-GPS response handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminModule
  participant GPS
  participant PositionModule
  participant Phone
  AdminModule->>GPS: requestPositionUpdate()
  GPS->>GPS: Validate, throttle, and schedule GPS sampling
  GPS->>PositionModule: sendOurPositionToPhone()
  PositionModule->>Phone: Forward valid requested position
Loading

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: requesting a current GPS position for the map.
Description check ✅ Passed The description provides a relevant summary, dependency information, and testing details; omitted template guidance and hardware attestations are non-critical.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@RCGV1
RCGV1 force-pushed the codex/gps-position-update branch from e8132b0 to f513b73 Compare August 11, 2026 09:01
@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/test_admin_radio/test_main.cpp (1)

57-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename the new test function to camelCase.

test_request_position_update_admin_message_round_trip is a C++ function and does not follow the required naming convention. Rename the declaration and update the RUN_TEST call at Line 1903.

As per coding guidelines, **/*.{cpp,h,cc,hh} requires camelCase functions and members.

Proposed rename
-static void test_request_position_update_admin_message_round_trip()
+static void testRequestPositionUpdateAdminMessageRoundTrip()
...
-    RUN_TEST(test_request_position_update_admin_message_round_trip);
+    RUN_TEST(testRequestPositionUpdateAdminMessageRoundTrip);

Also applies to: 1903-1903

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/test_admin_radio/test_main.cpp` at line 57, Rename
test_request_position_update_admin_message_round_trip to the required camelCase
form, and update the corresponding RUN_TEST invocation so the declaration and
test registration use the same name.

Source: Coding guidelines

src/modules/AdminModule.cpp (1)

690-703: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add runtime coverage for the position-update request path.

Cover unavailable GPS, first acceptance, and duplicate requests within 10 seconds. GPS::requestPositionUpdate() returns true for cooldown duplicates, so BAD_REQUEST applies only to rejected initialization or configuration cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/modules/AdminModule.cpp` around lines 690 - 703, Add runtime tests for
the request_position_update handler covering unavailable GPS, the first accepted
request, and duplicate requests within 10 seconds. Assert that accepted cooldown
duplicates remain successful because GPS::requestPositionUpdate() returns true,
while BAD_REQUEST is produced only when GPS initialization or configuration
rejects the request.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/gps/GPS.cpp`:
- Line 1610: Move the forwardPositionToPhone = false assignment from before
publishUpdate() to after the tooLong timeout handling completes, keeping the
flag set throughout the terminal timeout publication and clearing it only
afterward.

---

Nitpick comments:
In `@src/modules/AdminModule.cpp`:
- Around line 690-703: Add runtime tests for the request_position_update handler
covering unavailable GPS, the first accepted request, and duplicate requests
within 10 seconds. Assert that accepted cooldown duplicates remain successful
because GPS::requestPositionUpdate() returns true, while BAD_REQUEST is produced
only when GPS initialization or configuration rejects the request.

In `@test/test_admin_radio/test_main.cpp`:
- Line 57: Rename test_request_position_update_admin_message_round_trip to the
required camelCase form, and update the corresponding RUN_TEST invocation so the
declaration and test registration use the same name.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d6f62f97-de19-4dfd-9c0b-8f81a32b6c6c

📥 Commits

Reviewing files that changed from the base of the PR and between bcf486f and f513b73.

⛔ Files ignored due to path filters (1)
  • src/mesh/generated/meshtastic/admin.pb.h is excluded by !**/generated/**, !src/mesh/generated/**
📒 Files selected for processing (5)
  • protobufs
  • src/gps/GPS.cpp
  • src/gps/GPS.h
  • src/modules/AdminModule.cpp
  • test/test_admin_radio/test_main.cpp

Comment thread src/gps/GPS.cpp Outdated
@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Addressed the timeout ordering and test naming feedback, and added coverage for the unavailable-GPS rejection path. The accepted and coalesced paths require a live GPS worker and remain covered by the GPS request state logic.

@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/test_admin_radio/test_main.cpp`:
- Around line 1573-1575: Update the test flow after sendAdmin(request) to
inspect testAdmin->reply() and assert that its routing error is
meshtastic_Routing_Error_BAD_REQUEST before calling drainReply(). Replace the
insufficient non-null-only assertion while preserving the existing reply
draining.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: efc475ae-fbc4-4cfd-8adf-cc9abfd3c145

📥 Commits

Reviewing files that changed from the base of the PR and between f513b73 and 4e13034.

📒 Files selected for processing (2)
  • src/gps/GPS.cpp
  • test/test_admin_radio/test_main.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/gps/GPS.cpp

Comment thread test/test_admin_radio/test_main.cpp
@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Removed the generated binding change. This feature PR now follows the repository workflow and depends on protobuf PR #1032 plus its dedicated automated generated-binding update.

@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Updated the dependency to protobuf PR #1032 after rebasing it onto develop.

@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RCGV1

RCGV1 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant