Skip to content

Feat/mesh beacon#10618

Open
NomDeTom wants to merge 26 commits into
meshtastic:developfrom
NomDeTom:feat/mesh-beacon
Open

Feat/mesh beacon#10618
NomDeTom wants to merge 26 commits into
meshtastic:developfrom
NomDeTom:feat/mesh-beacon

Conversation

@NomDeTom
Copy link
Copy Markdown
Collaborator

@NomDeTom NomDeTom commented Jun 3, 2026

Building on the work in #7183 and brought back up in erayd#9.

Basically it brings in the "beacon" feature - a node (any node) can be configured either remotely or locally to swap to another preset, broadcast a message and return to the earlier preset at an interval of not less than an hour.

The node can send it "from" the admin-ing node as well, to help with consistency.

I've dropped the "tips" function and the channel admin-ing aspect. Once other 2.8 features are in place, maybe they can come back.

Supported by protobufs in meshtastic/protobufs#938.

Note: whitecollar code at the moment. Needs testing.

MeshBeacon Module

What it is

The MeshBeacon module lets a node periodically announce itself to the mesh with a configurable text message and/or a structured radio offer. Listeners store the offer; the client app can then invite the user to adopt it. The module has two independent halves:

  • Broadcaster (MeshBeaconBroadcastModule) — sends beacons on a timer.
  • Listener (MeshBeaconListenerModule) — receives beacons and caches the latest offer.

Both halves can be enabled independently; a pure-relay node might enable the listener but not the broadcaster, while a gateway might run both.


Use Cases

Scenario Config
Announce a migration channel to nearby nodes broadcast_enabled=true, broadcast_offer_preset, broadcast_offer_channel set, broadcast_message="Switch to NarrowSlow"
Publish a community text bulletin every hour broadcast_enabled=true, broadcast_message="Community net: 146.52 MHz at 8pm"

Configuration Reference

All fields are in moduleConfig.mesh_beacon (meshtastic_ModuleConfig_MeshBeaconConfig).

Feature flags

Field Type Default Description
listen_enabled bool true Accept incoming MESH_BEACON_APP packets. Delivers the text portion to the local inbox; caches the radio offer for the client app.
broadcast_enabled bool false Periodically send beacon packets from this node.

Broadcast content

Field Type Default Description
broadcast_message string (max 100 B) "" Text included in every beacon. When no offer fields are set, sent as TEXT_MESSAGE_APP so standard clients display it.
broadcast_send_as_node uint32 0 Override the from field. When 0, the local node number is used. A remote admin may only set this to their own node ID.
broadcast_interval_secs uint32 3600 How often to broadcast. Minimum 3600 (1 h). 0 = use default.

Radio offer (advertised to listeners)

Field Type Description
broadcast_offer_channel ChannelSettings (optional) Channel name + PSK to advertise. Listeners store this for the client app to present as a join offer.
broadcast_offer_region RegionCode Region to advertise in the offer.
broadcast_offer_preset ModemPreset (optional) Modem preset to advertise.

When any offer field is set, the packet uses MESH_BEACON_APP portnum and carries a structured protobuf payload. When none are set, the packet falls back to TEXT_MESSAGE_APP.

Note: offered settings are not applied by a node itself - it is transferred to a client app for review before applying.

Radio config for TX (where the beacon is sent)

Field Type Description
broadcast_on_channel ChannelSettings (optional) Override the channel used for TX. If only name/PSK differ from the primary, the radio switches to this channel for the beacon TX then restores.
broadcast_on_region RegionCode Override the region used for TX.
broadcast_on_preset ModemPreset (optional) Override the modem preset used for TX. If this differs from the running config, the radio is temporarily reconfigured for beacon TX, then restored.

These fields control where the beacon is transmitted, not what it advertises. A beacon can advertise one preset while being transmitted on a different one.

🤝 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)

erayd and others added 10 commits June 2, 2026 19:47
Note that this commit has details hardcoded for the Wellington (NZ)
mesh, and also requires the following patch to the protobufs:

-----
diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto
index 03162d8..ec54c99 100644
--- a/meshtastic/mesh.proto
+++ b/meshtastic/mesh.proto
@@ -1393,6 +1393,21 @@ message MeshPacket {
    * Set by the firmware internally, clients are not supposed to set this.
    */
   uint32 tx_after = 20;
+
+  /*
+   * The modem preset to use fo rthis packet
+   */
+  uint32 modem_preset = 21;
+
+  /*
+   * The frequency slot to use for this packet
+   */
+  uint32 frequency_slot = 22;
+
+  /*
+   * Whether the packet has a nonstandard radio config
+   */
+  bool nonstandard_radio_config = 23;
 }

 /*
-----
…on + proto cache

- MeshBeaconBroadcastModule now inherits ProtobufModule<meshtastic_MeshBeacon>
  (alongside private MeshBeaconModule + OSThread), giving it allocDataPacket()
  and setStartDelay() without extra includes.

- Payload cache: rebuildCache() encodes the MeshBeacon protobuf once and stores
  it in payloadCache[]/payloadCacheSize; sendBeacon() only calls rebuildCache()
  when payloadCacheDirty==true. AdminModule calls invalidateCache() after saving
  new config so the next broadcast picks up changes.

- Region/preset validation in handleSetModuleConfig (mesh_beacon_tag):
  broadcast_on_preset is validated against the device's current region via
  RadioInterface::validateConfigLora(); broadcast_offer_region is validated via
  RadioInterface::validateConfigRegion(). Invalid values are zeroed with a
  LOG_WARN before saving.
@NomDeTom NomDeTom requested review from GUVWAF and Copilot June 3, 2026 02:59
@github-actions github-actions Bot added the needs-review Needs human review label Jun 3, 2026
@NomDeTom NomDeTom requested review from caveman99 and removed request for GUVWAF June 3, 2026 02:59
@github-actions github-actions Bot added the enhancement New feature or request label Jun 3, 2026
@NomDeTom NomDeTom requested a review from GUVWAF June 3, 2026 02:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 introduces a new Mesh Beacon feature to Meshtastic firmware: nodes can periodically broadcast a “beacon” message (optionally including an offer of radio/channel settings) and temporarily switch modem preset/channel parameters for beacon TX, integrating with the existing module and RadioLib TX pipeline.

Changes:

  • Adds MeshBeaconBroadcastModule (periodic sender with payload caching) and MeshBeaconListenerModule (receives beacons, delivers text to inbox, caches offers).
  • Extends module configuration/protobuf surface to represent beacon settings and introduces a new MESH_BEACON_APP portnum.
  • Hooks RadioLib transmit flow to support per-packet temporary radio reconfiguration for beacon transmissions, plus adds a Unity unit test suite for the new module.

Reviewed changes

Copilot reviewed 11 out of 18 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/modules/MeshBeaconModule.h Declares beacon broadcast/listen modules and radio-switch sidecar helpers.
src/modules/MeshBeaconModule.cpp Implements beacon TX/RX logic, payload caching, and radio reconfiguration/restore behavior.
src/modules/AdminModule.cpp Adds validation/sanitization for MeshBeacon module config on set-module-config.
src/modules/AdminModule.h Adjusts visibility of handleSetModuleConfig under unit testing for test access.
src/modules/Modules.cpp Registers/instantiates beacon modules during module setup.
src/mesh/RadioLibInterface.cpp Integrates beacon radio switching into TX timing/ISR flow and clears sidecar entries after send.
src/mesh/MeshRadio.h Exposes getRegion() for beacon config validation.
src/mesh/Channels.h Makes Channels::fixupChannel() public (used during temporary channel-name/hash adjustments).
src/mesh/Default.h Adds a beacon interval constant used for minimum/default scheduling.
src/mesh/generated/meshtastic/portnums.pb.h Adds meshtastic_PortNum_MESH_BEACON_APP = 37.
src/mesh/generated/meshtastic/mesh_beacon.pb.{h,cpp} Adds generated nanopb types for the MeshBeacon payload.
src/mesh/generated/meshtastic/module_config.pb.{h,cpp} Adds generated nanopb types for MeshBeacon module config.
src/mesh/generated/meshtastic/localonly.pb.h Extends LocalModuleConfig to include MeshBeacon config.
src/mesh/generated/meshtastic/deviceonly.pb.h Updates generated size constants to reflect schema changes.
test/test_mesh_beacon/test_main.cpp Adds unit tests covering admin validation, broadcaster cache/packet formation, and listener caching/guards.

Comment thread src/modules/Modules.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp
Comment thread src/modules/MeshBeaconModule.cpp
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/AdminModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 20 changed files in this pull request and generated 7 comments.

Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/MeshBeaconModule.cpp Outdated
Comment thread src/modules/AdminModule.cpp
Comment thread src/mesh/NodeDB.cpp
Comment thread test/test_mesh_beacon/test_main.cpp Outdated
@SpudGunMan
Copy link
Copy Markdown

What about a QSY request as part of it to move/change?

NomDeTom and others added 6 commits June 4, 2026 00:48
Co-authored-by: NomDeTom <116762865+NomDeTom@users.noreply.github.com>
Co-authored-by: NomDeTom <116762865+NomDeTom@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Firmware Size Report

21 targets | no baseline available yet

Target Size
elecrow-adv-35-tft 3,364,928
heltec-ht62-esp32c3-sx1262 2,087,024
heltec-v3 2,208,080
heltec-vision-master-e213-inkhud 2,172,688
pico 739,608
Show 16 more target(s)
Target Size
pico2 732,200
pico2w 1,180,628
picow 1,199,416
rak11200 1,804,400
rak11310 762,184
rak3172 182,696
rak3312 2,214,656
seeed-xiao-s3 2,218,016
seeed_xiao_rp2040 737,800
seeed_xiao_rp2350 730,360
station-g2 2,218,672
station-g3 2,209,472
t-deck-tft 3,754,416
t-eth-elite 2,435,408
tlora-c6 2,318,992
wio-e5 234,188

Updated for 0ae3200

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

Labels

enhancement New feature or request needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants