Skip to content

Rssi explicit presence - #1024

Merged
thebentern merged 2 commits into
meshtastic:masterfrom
NomDeTom:rssi-explicit-presence
Jul 28, 2026
Merged

Rssi explicit presence#1024
thebentern merged 2 commits into
meshtastic:masterfrom
NomDeTom:rssi-explicit-presence

Conversation

@NomDeTom

@NomDeTom NomDeTom commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

make rx_rssi optional

needed for meshtastic/firmware#11271

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of signal-strength readings so valid 0 dB values are distinguished from unavailable measurements.
    • Clarified how unknown signal and hop information is represented, including for replayed or historical packets.
    • Improved accuracy of quarter-decibel SNR values through rounded encoding.
  • Documentation

    • Updated protocol guidance to clarify when signal and hop values should be considered unknown.

NomDeTom added 2 commits July 28, 2026 11:01
…Lite.rssi storage field

MeshPacket.rx_rssi was proto3 singular, so an unset value and a genuine
0 dBm reading were byte-identical on the wire (0 is a legal SX126x return,
and SX127x's offset+register formula can even go positive). Mark it
optional so absence survives encoding, mirroring the precedent already set
by NodeInfo.hops_away.

NodeInfoLite had no RSSI field at all, so nothing survived a device
reboot for replayed history packets to restore - every replay showed
RSSI 0 regardless of the real measurement. Add NodeInfoLite.rssi (tag 20,
sint32, next free tag) with the same "0 is not automatically unknown"
caveat; presence is tracked via NODEINFO_BITFIELD_HAS_RSSI on the
firmware side rather than a second wire-level bool, to avoid a RAM cost
per stored node.

Companion firmware change: meshtastic/firmware, phantom-node-fix-perhaps
branch, .notes/plans/plan-executed-snr-rssi-replay-fidelity.md.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updated protobuf documentation for Q4 SNR encoding and persisted zero values. Changed MeshPacket.rx_rssi to an optional field and clarified rx_rssi presence and legacy hop_start interpretation.

Changes

Protocol semantics

Layer / File(s) Summary
NodeInfoLite SNR encoding semantics
meshtastic/deviceonly.proto
Documents rounded Q4 SNR encoding and distinguishes unknown persisted zero values using NODEINFO_BITFIELD_HAS_SNR.
MeshPacket presence and hop semantics
meshtastic/mesh.proto
Makes rx_rssi optional and documents zero-value disambiguation plus legacy hop_start == 0 handling.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: thebentern, jp-bennett, caveman99

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and does not follow the required PR template sections or checklist. Rewrite the PR description using the template, including the "What does this PR do?" section, related issue link, and checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: making RSSI presence explicit.
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

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.

@NomDeTom
NomDeTom requested a review from thebentern July 28, 2026 14:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@meshtastic/deviceonly.proto`:
- Around line 190-196: Add the persistent RSSI field to the NodeInfoLite message
after snr_q4, using the documented sint32 rssi = 20 declaration. Ensure
persistence and history replay use this field, and interpret a zero RSSI value
through NODEINFO_BITFIELD_HAS_RSSI rather than treating zero as inherently
unknown.
🪄 Autofix (Beta)

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: 288a599c-92ef-4fc1-8d94-161f09666f11

📥 Commits

Reviewing files that changed from the base of the PR and between bfd718f and 94cdec4.

📒 Files selected for processing (2)
  • meshtastic/deviceonly.proto
  • meshtastic/mesh.proto

Comment on lines +190 to 196
* Encode: snr_q4 = (int32_t)lroundf(snr * 4.0f). Decode: snr = snr_q4 / 4.0f.
* float snr is always zeroed on disk; this field carries all persisted SNR.
* A stored 0 does not by itself mean "unknown" here - see NODEINFO_BITFIELD_HAS_SNR in
* src/mesh/NodeDB.h for the presence bit that disambiguates a genuine 0 dB reading from
* "never measured".
*/
sint32 snr_q4 = 19;

@coderabbitai coderabbitai Bot Jul 28, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Add the required persistent RSSI field to NodeInfoLite.

The supplied message ends at snr_q4 = 19; it has no rssi = 20 field. Making MeshPacket.rx_rssi optional preserves presence in packets, but cannot persist RSSI across reboots or history replay as required by this PR. Add the documented sint32 rssi = 20 field and ensure its zero-value interpretation uses NODEINFO_BITFIELD_HAS_RSSI.

🤖 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 `@meshtastic/deviceonly.proto` around lines 190 - 196, Add the persistent RSSI
field to the NodeInfoLite message after snr_q4, using the documented sint32 rssi
= 20 declaration. Ensure persistence and history replay use this field, and
interpret a zero RSSI value through NODEINFO_BITFIELD_HAS_RSSI rather than
treating zero as inherently unknown.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

semantic disagreement, maybe. Can you explain why I need to add a new protobuf?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- NodeInfoLite RSSI / SNR field declarations ---'
rg -n -C 3 '\brssi\b|\bsnr_q4\b' meshtastic/deviceonly.proto

printf '%s\n' '--- RSSI presence bit references ---'
rg -n -C 4 'NODEINFO_BITFIELD_HAS_RSSI|NODEINFO_BITFIELD_HAS_SNR' .

printf '%s\n' '--- NodeInfoLite RSSI assignment/read references ---'
rg -n -C 4 '(NodeInfoLite|node_info|nodeinfo).*rssi|\.rssi\b|->rssi\b' \
  -g '!meshtastic/deviceonly.proto' .

Length of output: 2434


@NomDeTom, fair disagreement — and I should have said a new field in the existing NodeInfoLite protobuf, not “a new protobuf.”

There are two separate persistence cases:

  1. Packet history / receive queue
    DeviceState.receive_queue stores MeshPackets. Making MeshPacket.rx_rssi optional is sufficient to preserve whether that packet had an RSSI reading, including a valid 0 value, when the packet is serialized and replayed.

  2. Latest per-node state after reboot
    NodeDatabase.nodes stores NodeInfoLite, not the packet history. If firmware expects the current/latest RSSI for each node to remain available after a reboot even when the original packet is no longer consulted, then NodeInfoLite needs a persisted RSSI value plus a presence indicator. That is analogous to the existing snr/snr_q4 arrangement.

So: you do not need NodeInfoLite.rssi merely for replaying MeshPacket history. It is needed only if the PR’s intended contract includes persisting the per-node “last RSSI” independently of those packets.

The current protobuf repository has no NODEINFO_BITFIELD_HAS_RSSI definition or firmware read/write path to validate that latter contract; those belong to the related firmware work. My original finding incorrectly bundled packet replay and node-state persistence together.

@thebentern
thebentern merged commit 26db1b5 into meshtastic:master Jul 28, 2026
3 of 4 checks passed
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.

2 participants