Skip to content

Fix replayed satellite-DB packets masquerading as fresh live traffic - #11014

Merged
thebentern merged 1 commit into
meshtastic:developfrom
NomDeTom:satellite-db-replay
Jul 16, 2026
Merged

Fix replayed satellite-DB packets masquerading as fresh live traffic#11014
thebentern merged 1 commit into
meshtastic:developfrom
NomDeTom:satellite-db-replay

Conversation

@NomDeTom

@NomDeTom NomDeTom commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Position/telemetry/environment/status records replayed to the phone after config_complete_id were built to look exactly like a live over-the-air broadcast (fresh random packet id, zeroed rx_snr, hop_start == hop_limit), so on every reconnect the client logged them as brand-new packets and reset the node's rssi/snr/hops-away/last-heard as if just received directly.

Populate rx_snr and derive hop_start/hop_limit from the node's real last-known snr/hops_away, and use a stable id derived from (node, timestamp, record kind) so unchanged history replayed on reconnect no longer reads as new.

🤝 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
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)
      Pro-micro DIY

Summary by CodeRabbit

  • Bug Fixes
    • Improved replayed satellite database packets so they remain consistent and can be correctly deduplicated after reconnects.
    • Preserved accurate hop information for replayed position, telemetry, environment, and status packets.
    • Continued reporting reception time and signal quality for replayed packets.

@NomDeTom
NomDeTom requested review from Copilot and thebentern July 15, 2026 15:02
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PhoneAPI replay packet construction now derives stable identifiers from node records and computes hop fields from stored node information for Position, Telemetry, Environment, and Status packets.

Changes

Replay packet metadata

Layer / File(s) Summary
Stable replay identifiers and hop fields
src/mesh/PhoneAPI.cpp
Adds helpers for stable record-based packet IDs and node-aware hop fields, then applies them to replayed Position, Telemetry, Environment, and Status packets.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Suggested reviewers: thebentern, jp-bennett

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: replayed satellite-DB packets are made to no longer appear as fresh live traffic.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (28)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Meshnology W10 meshnology_w10 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Repeater Mini V2 rak_wismesh_repeater_mini nrf52840
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed SenseCAP Mesh-Tracker-X1 seeed_mesh_tracker_X1 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LILYGO T-Impulse Plus t-impulse-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-08-14. Updated for eb777af.

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

🧹 Nitpick comments (3)
src/mesh/PhoneAPI.cpp (3)

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

Remove the redundant comment.

This comment restates what the subsequent makeReplayPacketId call obviously does, which violates the project's coding guidelines. As per coding guidelines: "Keep code comments minimal... only when the reason is not obvious... or restate what the next line does."

♻️ Proposed refactor
-    // Stable per-node/per-fix id: replaying the same unchanged history on every
-    // reconnect must not look like a brand new packet to the phone's history/dedup.
🤖 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/mesh/PhoneAPI.cpp` around lines 1241 - 1242, Remove the redundant comment
immediately preceding the makeReplayPacketId call in the replay packet handling
code, leaving the call and surrounding implementation unchanged.

Source: Coding guidelines


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

Condense the multi-line explanatory comment.

This 6-line comment violates the project's coding guidelines. As per coding guidelines: "Keep code comments minimal: use at most one or two lines, only when the reason is not obvious; do not add multi-paragraph explanatory comments".

♻️ Proposed refactor
-/// Derive a stable id for a replayed satellite-DB record. Unchanged history replayed on
-/// every reconnect must not look like a new packet to the phone's history/dedup - the id
-/// only changes when the underlying data (its timestamp) actually changes.
-// `kind` only needs to distinguish the record types that can otherwise collide (e.g. device
-// vs. environment metrics both replay as TELEMETRY_APP with the same node/last_heard) - pass
-// the payload's own variant/port constant.
+/// Derive a stable id for a replayed record based on node, timestamp, and kind.
🤖 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/mesh/PhoneAPI.cpp` around lines 1206 - 1211, Condense the explanatory
comment above the stable replayed-record ID logic into at most one or two lines,
retaining only the essential purpose: the ID remains stable across unchanged
replays and uses the payload variant to distinguish record types.

Source: Coding guidelines


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

Condense the multi-line explanatory comment.

This 3-line comment violates the project's coding guidelines. As per coding guidelines: "Keep code comments minimal: use at most one or two lines, only when the reason is not obvious; do not add multi-paragraph explanatory comments".

♻️ Proposed refactor
-    // Shape this exactly like a fresh live broadcast Position from the peer so the
-    // phone runs it through its normal "live position broadcast" handler path.
-    // to=ourNum would read as a DM-from-peer and never lands in node detail UI.
+    // Shape as a fresh broadcast so the phone routes it to the node detail UI.
🤖 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/mesh/PhoneAPI.cpp` around lines 1233 - 1235, Condense the three-line
comment in the live broadcast position handling near the shown code into one or
two concise lines, retaining only the essential reason for shaping the message
like a peer’s fresh live broadcast and avoiding DM routing.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@src/mesh/PhoneAPI.cpp`:
- Around line 1241-1242: Remove the redundant comment immediately preceding the
makeReplayPacketId call in the replay packet handling code, leaving the call and
surrounding implementation unchanged.
- Around line 1206-1211: Condense the explanatory comment above the stable
replayed-record ID logic into at most one or two lines, retaining only the
essential purpose: the ID remains stable across unchanged replays and uses the
payload variant to distinguish record types.
- Around line 1233-1235: Condense the three-line comment in the live broadcast
position handling near the shown code into one or two concise lines, retaining
only the essential reason for shaping the message like a peer’s fresh live
broadcast and avoiding DM routing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f6c1c7c-c20f-43cc-b0ee-fdfb475fe86f

📥 Commits

Reviewing files that changed from the base of the PR and between 834357e and eb777af.

📒 Files selected for processing (1)
  • src/mesh/PhoneAPI.cpp

@NomDeTom NomDeTom added the enhancement New feature or request label Jul 15, 2026

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 adjusts how PhoneAPI replays satellite-DB history packets (position/telemetry/environment/status) to connected clients so they no longer appear as newly received over-the-air traffic on every reconnect. It does this by stabilizing replay packet IDs and by populating link metadata (SNR and hop fields) using the node’s last-known RF characteristics.

Changes:

  • Introduces a deterministic replay packet ID generator (makeReplayPacketId) so unchanged replayed history deduplicates cleanly across reconnects.
  • Populates rx_snr and derives hop_start/hop_limit from NodeInfoLite (via setReplayHopFields) to preserve realistic “heard” metadata for replayed packets.
  • Applies the above consistently across replayed position, device metrics telemetry, environment metrics telemetry, and node status packets.

@thebentern
thebentern merged commit 35ab69a into meshtastic:develop Jul 16, 2026
100 of 102 checks passed
@NomDeTom
NomDeTom deleted the satellite-db-replay branch July 23, 2026 19:50
This was referenced Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants