Skip to content

Add configurable event mode hop limit - #11275

Merged
thebentern merged 8 commits into
meshtastic:developfrom
RCGV1:codex/event-mode-hop-count
Jul 29, 2026
Merged

Add configurable event mode hop limit#11275
thebentern merged 8 commits into
meshtastic:developfrom
RCGV1:codex/event-mode-hop-count

Conversation

@RCGV1

@RCGV1 RCGV1 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Add USERPREFS_EVENT_MODE_HOP_LIMIT as the event profile's baked default hop count and firmware-generated/relay cap.
  • Accept integer values from 0 through 7, preserve the existing default of 3 when omitted, and reject invalid values at compile time.
  • Reuse the existing Default owner plus one local relay helper; no separate event-mode abstraction is added.
  • Apply the selected value to new event profiles, firmware-generated responses, and decoded and opaque relay paths while preserving explicit client-forced hop limits.
  • Keep relay hop_start adjustments consistent and safe for legacy packets where hop_start == 0.

Why

Event mode previously hard-coded a default hop count of three in multiple routing paths. Event builds need to choose that baked default without patching firmware sources, while retaining the current behavior when the preference is not set.

Validation

  • trunk fmt — clean across all 8 changed files.
  • ~/.platformio/penv/bin/python -m platformio test -e native-macos — 792/792 tests passed across 39 suites.
  • Focused event-mode tests passed with hop limits 0, 5, and 7, covering firmware responses, decoded and opaque relays, legacy hop_start, and explicit client overrides.
  • Invalid values 8 and 7.5 failed compilation through the intended static_assert.
  • ~/.platformio/penv/bin/pio run -e heltec-v3 — succeeded with USERPREFS_EVENT_MODE=1 and USERPREFS_EVENT_MODE_HOP_LIMIT=5.
  • No physical device flashing or hardware regression testing was performed.

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

Summary by CodeRabbit

  • New Features
    • Added configurable hop limits for event mode (0–7, default 3).
    • Event-mode routing/relaying now consistently caps hop limits, including adjusted hop-start behavior for opaque relays.
    • Response hop counts are capped correctly when event mode is enabled.
  • Bug Fixes
    • Improved rebroadcast/relay hop handling to align with the configured event-mode limits.
  • Documentation
    • Documented the optional event-mode hop-limit preference in the user preferences file.
  • Tests
    • Added event-mode unit tests covering hop-limit/hop-start capping behavior.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a5bced9-ca13-4126-9a91-1a4062d73138

📥 Commits

Reviewing files that changed from the base of the PR and between 8f494fb and f5bcd5f.

📒 Files selected for processing (2)
  • src/mesh/Default.cpp
  • test/test_default/test_main.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/test_default/test_main.cpp
  • src/mesh/Default.cpp

📝 Walkthrough

Walkthrough

Event mode gains validated configurable hop limits, applies them to default configuration, routing responses, rebroadcasts, and opaque relays, and adds unit coverage for response and relay hop-field behavior.

Changes

Event-mode hop limits

Layer / File(s) Summary
Hop-limit contract and configuration
src/mesh/Default.h, userPrefs.jsonc
Defines validated event-mode hop-limit and relay-hop-limit constants and documents the optional preference.
Default and response hop limits
src/mesh/Default.cpp, src/mesh/NodeDB.cpp, src/modules/RoutingModule.cpp, test/test_default/test_main.cpp
Applies event-mode limits to configured defaults and routing responses, with conditional unit coverage.
Relay hop-field capping
src/mesh/NextHopRouter.cpp, test/test_nexthop_routing/test_main.cpp
Caps relay hop_limit and adjusts hop_start for opaque relays and rebroadcasts, with event-mode tests and mock capture fields.

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

Sequence Diagram(s)

sequenceDiagram
  participant NextHopRouter
  participant capEventRelayHops
  participant MockRadioInterface
  NextHopRouter->>capEventRelayHops: cap relay hop fields
  capEventRelayHops-->>NextHopRouter: return adjusted packet
  NextHopRouter->>MockRadioInterface: send adjusted packet
Loading

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: thebentern

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a configurable event mode hop limit.
Description check ✅ Passed The description covers summary, motivation, validation, and attestations, with the required testing details mostly complete.
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.

@RCGV1
RCGV1 marked this pull request as ready for review July 29, 2026 00:46
@github-actions

github-actions Bot commented Jul 29, 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 (31)
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
Meshnology W12 meshnology_w12 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Pocket V3 rak_wismesh_pocket nrf52840
RAK WisMesh Pod rak_wismesh_pod nrf52840
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-28. Updated for f5bcd5f.

@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 `@src/mesh/Default.cpp`:
- Line 95: Update the limit comparison in the relevant Default hop-limit
calculation to use >= so configured == eventModeHopLimit returns the event cap,
including when configured is 0. Add a test that passes
Default::eventModeHopLimit with config.lora.hop_limit set to HOP_MAX and
verifies the capped result.
🪄 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: 6f8c7b69-7eec-4f0c-87db-a1dd2b5f6c1f

📥 Commits

Reviewing files that changed from the base of the PR and between 925621a and 8f494fb.

📒 Files selected for processing (6)
  • src/mesh/Default.cpp
  • src/mesh/Default.h
  • src/mesh/NextHopRouter.cpp
  • src/mesh/NodeDB.cpp
  • test/test_default/test_main.cpp
  • test/test_nexthop_routing/test_main.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/mesh/NodeDB.cpp

Comment thread src/mesh/Default.cpp Outdated
@vidplace7 vidplace7 added the enhancement New feature or request label Jul 29, 2026
@vidplace7
vidplace7 requested a review from thebentern July 29, 2026 10:48
@thebentern
thebentern added this pull request to the merge queue Jul 29, 2026
Merged via the queue into meshtastic:develop with commit 0fef83d Jul 29, 2026
100 of 102 checks passed
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