Skip to content

Commit f680aac

Browse files
authored
Merge pull request #939 from NomDeTom/feat/mesh-beacon
Feat/mesh beacon
2 parents b0875eb + 2ab813c commit f680aac

6 files changed

Lines changed: 207 additions & 0 deletions

File tree

meshtastic/localonly.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ message LocalModuleConfig {
146146
*/
147147
ModuleConfig.TAKConfig tak = 17;
148148

149+
/*
150+
* MeshBeacon Config
151+
*/
152+
ModuleConfig.MeshBeaconConfig mesh_beacon = 18;
153+
149154
/*
150155
* A version integer used to invalidate old save files when we make
151156
* incompatible changes This integer is set at build time and is private to

meshtastic/mesh_beacon.options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*MeshBeacon.message max_size:101
2+
*MeshBeacon.offer_channel.name max_size:12
3+
*MeshBeacon.offer_channel.psk max_size:32

meshtastic/mesh_beacon.proto

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
syntax = "proto3";
2+
3+
package meshtastic;
4+
5+
import "meshtastic/channel.proto";
6+
import "meshtastic/config.proto";
7+
8+
option csharp_namespace = "Meshtastic.Protobufs";
9+
option go_package = "github.com/meshtastic/go/generated";
10+
option java_outer_classname = "MeshBeaconProtos";
11+
option java_package = "org.meshtastic.proto";
12+
option swift_prefix = "";
13+
14+
/*
15+
* Payload for MESH_BEACON_APP packets.
16+
* Periodically broadcast by nodes in beacon mode.
17+
* Listeners deliver the text message to the local inbox and cache any offered
18+
* channel/preset for the client app to act on — the firmware never auto-applies them.
19+
*/
20+
message MeshBeacon {
21+
/*
22+
* Human-readable beacon message. Max 100 bytes enforced by firmware on send.
23+
*/
24+
string message = 1;
25+
26+
/*
27+
* Optional channel (name + PSK) being advertised to listening clients.
28+
* A client app may offer to switch the user to this channel; firmware never applies it automatically.
29+
*/
30+
ChannelSettings offer_channel = 2;
31+
32+
/*
33+
* Optional region being advertised alongside offer_preset.
34+
*/
35+
Config.LoRaConfig.RegionCode offer_region = 3;
36+
37+
/*
38+
* Optional modem preset being advertised.
39+
* Combined with offer_region, tells a client "there is a mesh on this preset/region".
40+
*/
41+
optional Config.LoRaConfig.ModemPreset offer_preset = 4;
42+
}

meshtastic/module_config.options

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@
2929
*DetectionSensorConfig.detection_trigger_type max_size:8
3030

3131
*StatusMessageConfig.node_status max_size:80
32+
33+
*MeshBeaconConfig.broadcast_message max_size:101
34+
*MeshBeaconConfig.broadcast_offer_channel.name max_size:12
35+
*MeshBeaconConfig.broadcast_offer_channel.psk max_size:32
36+
*MeshBeaconConfig.broadcast_on_channel.name max_size:12
37+
*MeshBeaconConfig.broadcast_on_channel.psk max_size:32
38+
*MeshBeaconConfig.broadcast_targets max_count:4

meshtastic/module_config.proto

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ syntax = "proto3";
33
package meshtastic;
44

55
import "meshtastic/atak.proto";
6+
import "meshtastic/channel.proto";
7+
import "meshtastic/config.proto";
68

79
option csharp_namespace = "Meshtastic.Protobufs";
810
option go_package = "github.com/meshtastic/go/generated";
@@ -827,6 +829,141 @@ message ModuleConfig {
827829
string node_status = 1;
828830
}
829831

832+
/*
833+
* MeshBeacon module config
834+
*/
835+
message MeshBeaconConfig {
836+
/*
837+
* Boolean options for the beacon module, packed into the `flags` bitfield below.
838+
* OR the FLAG_* values together; a flag is on when its bit is set.
839+
*/
840+
enum Flags {
841+
/*
842+
* No options enabled.
843+
*/
844+
FLAG_NONE = 0;
845+
846+
/*
847+
* Enable receiving MESH_BEACON_APP packets from other nodes.
848+
* The text portion is delivered to the local message inbox.
849+
* Offered channel/preset are stored for the client app to act on.
850+
*/
851+
FLAG_LISTEN_ENABLED = 1;
852+
853+
/*
854+
* Enable periodically broadcasting MESH_BEACON_APP packets from this node.
855+
*/
856+
FLAG_BROADCAST_ENABLED = 2;
857+
858+
/*
859+
* When both text and offer content are present, split the beacon into a separate
860+
* MESH_BEACON_APP (offer only) and TEXT_MESSAGE_APP (text only) packet, so firmware
861+
* that only decodes TEXT_MESSAGE_APP still receives the human-readable text.
862+
*/
863+
FLAG_LEGACY_SPLIT = 4;
864+
}
865+
866+
/*
867+
* Bitwise-OR of Flags values (listen / broadcast / legacy-split toggles).
868+
*/
869+
uint32 flags = 1;
870+
871+
/*
872+
* Optional: node ID to send beacon messages AS.
873+
* When set, the `from` field of outgoing beacon packets is set to this node ID,
874+
* making beacons appear to originate from that node.
875+
* When unset (0), beacons are sent as the local node.
876+
* A remote admin can only set this field to their own node ID.
877+
*/
878+
uint32 broadcast_send_as_node = 3;
879+
880+
/*
881+
* Message to include in each beacon broadcast. Max 100 bytes enforced by firmware.
882+
*/
883+
string broadcast_message = 4;
884+
885+
/*
886+
* Optional channel (name + PSK) to advertise in the MeshBeacon offer_channel field.
887+
*/
888+
ChannelSettings broadcast_offer_channel = 5;
889+
890+
/*
891+
* Optional region to advertise in the MeshBeacon offer_region field.
892+
*/
893+
Config.LoRaConfig.RegionCode broadcast_offer_region = 6;
894+
895+
/*
896+
* Optional modem preset to advertise in the MeshBeacon offer_preset field.
897+
*/
898+
optional Config.LoRaConfig.ModemPreset broadcast_offer_preset = 7;
899+
900+
/*
901+
* Single-target TX channel: channel settings (name + PSK) to send beacons on.
902+
* If unset, beacons go out on the primary channel. Used only when broadcast_targets is empty.
903+
* NOTE: the single-target path embeds the ChannelSettings inline here, whereas a
904+
* broadcast_targets entry references a channel-table slot by channel_index instead — see
905+
* BroadcastTarget. The two paths are equal, first-class options; only this representation differs.
906+
*/
907+
ChannelSettings broadcast_on_channel = 8;
908+
909+
/*
910+
* Region to use when sending beacons on broadcast_on_preset.
911+
*/
912+
Config.LoRaConfig.RegionCode broadcast_on_region = 9;
913+
914+
/*
915+
* Modem preset to use when sending beacons.
916+
* If different from current config, the radio is temporarily switched for TX.
917+
*/
918+
optional Config.LoRaConfig.ModemPreset broadcast_on_preset = 10;
919+
920+
/*
921+
* How often to broadcast, in seconds. Min 3600 (1 h), default 3600.
922+
*/
923+
uint32 broadcast_interval_secs = 11;
924+
925+
/*
926+
* One entry in the multi-target broadcast list.
927+
* The broadcaster transmits one beacon copy per entry, each on its own radio settings.
928+
*/
929+
message BroadcastTarget {
930+
/*
931+
* Modem preset to use for this target.
932+
* Falls back to the running config preset if unset.
933+
*/
934+
optional Config.LoRaConfig.ModemPreset preset = 1;
935+
936+
/*
937+
* Region to use for this target. UNSET means use the running config region.
938+
*/
939+
Config.LoRaConfig.RegionCode region = 2;
940+
941+
// Tag 3 was an embedded ChannelSettings; replaced by channel_index (tag 4) to keep
942+
// ModuleConfig within the BLE FromRadio size budget. Branch unreleased, so tag 3 is a gap.
943+
944+
/*
945+
* Index into the device's channel table (0..MAX_NUM_CHANNELS-1) of the channel to
946+
* transmit this target's beacon on. The referenced channel must already be configured
947+
* on the node (its key is needed to encrypt). If unset, the default channel for the
948+
* preset is used.
949+
*/
950+
optional uint32 channel_index = 4;
951+
}
952+
953+
/*
954+
* Multi-target broadcast list.
955+
* When non-empty the broadcaster transmits one beacon copy per entry in sequence,
956+
* each temporarily switching the radio to that entry's preset/region/channel.
957+
* When empty, the broadcaster uses the scalar broadcast_on_preset / broadcast_on_region /
958+
* broadcast_on_channel fields instead (the single-target path).
959+
* Single- and multi-target are equal, first-class options — neither is preferred or
960+
* deprecated. They differ only in how the TX channel is named: broadcast_on_channel embeds a
961+
* ChannelSettings inline, while a target references an existing channel-table slot by
962+
* channel_index (see BroadcastTarget).
963+
*/
964+
repeated BroadcastTarget broadcast_targets = 13;
965+
}
966+
830967
/*
831968
* TODO: REPLACE
832969
*/
@@ -910,6 +1047,11 @@ message ModuleConfig {
9101047
* TAK team/role configuration for TAK_TRACKER
9111048
*/
9121049
TAKConfig tak = 16;
1050+
1051+
/*
1052+
* MeshBeacon module config
1053+
*/
1054+
MeshBeaconConfig mesh_beacon = 17;
9131055
}
9141056

9151057
/*

meshtastic/portnums.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ enum PortNum {
155155
*/
156156
NODE_STATUS_APP = 36;
157157

158+
/*
159+
* Beacon module broadcast packets.
160+
* ENCODING: protobuf
161+
* Periodically broadcast by nodes in beacon mode; received by nodes with MeshBeaconConfig.FLAG_LISTEN_ENABLED.
162+
* Carries a text message plus optional channel/preset offers for client apps.
163+
*/
164+
MESH_BEACON_APP = 37;
165+
158166
/*
159167
* Provides a hardware serial interface to send and receive from the Meshtastic network.
160168
* Connect to the RX/TX pins of a device with 38400 8N1. Packets received from the Meshtastic

0 commit comments

Comments
 (0)