mirror of
https://github.com/meshtastic/firmware.git
synced 2026-11-06 22:34:13 -05:00
Gut beacon send-as-node and consolidate TX onto broadcast_targets (#11646)
* Gut beacon send-as-node and consolidate TX onto broadcast_targets Two MeshBeaconConfig changes, both against fields that never reached a tagged release, so there is no migration for existing nodes. broadcast_send_as_node let a client name a node ID to send beacons AS, rewriting the packet's `from`. Firmware never applied it - the assignment was commented out, so `from` was always the local node and the field was a settable, persisted no-op. It was also unsound as designed: rewriting `from` forges no signature, it only makes isFromUs() false, so perhapsEncode() skips XEdDSA signing and receivers get an unsigned packet attributed to another node. broadcast_on_channel / broadcast_on_region / broadcast_on_preset were a second way to name a beacon destination alongside broadcast_targets, chosen silently on whether broadcast_targets was empty. The comments claimed the two were equivalent; they were not. An inline ChannelSettings carries name and PSK, so broadcast_on_channel could transmit on a channel absent from the node's channel table, which channel_index cannot express. That is dropped deliberately - the channel must exist on the node. Empty broadcast_targets now synthesises one target on the running preset and region over the primary channel, matching what the scalar path produced when left unset, so an otherwise unconfigured node still beacons. The USERPREFS_MESH_BEACON_ON_* keys go with the fields. A preconfigured build that still defines one now fails at compile time with a pointer to the USERPREFS_MESH_BEACON_TARGET_0_* equivalents, rather than silently losing its beacon channel. The replacement names a channel-table slot, so such a build must also provision that channel. MeshBeaconConfig shrinks 324 -> 240 bytes and ModuleConfig 328 -> 244, against the 512-byte MAX_TO_FROM_RADIO_SIZE ceiling that FromRadio sits 2 bytes under. The protobufs submodule points at a branch carrying both proto changes; it needs re-pointing to master once meshtastic/protobufs#1047 and #1048 merge. * Point protobufs submodule at master now that the beacon protos are merged meshtastic/protobufs#1047 and #1048 are in master, so drop the temporary beacon-proto-integration pin. MeshBeaconConfig stays 240 bytes and ModuleConfig 244, unchanged from the integration branch. The bump also picks up master's unrelated additions: the MESHNOLOGY_W12 and MESHPAGER_X2 hardware models, and a ground-speed unit correction in Position.
This commit is contained in:
1 parent
78219e09cb
commit
7afd270f39
12 files changed
+106
-253
No files matched your search
@@ -343,17 +343,6 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
||||
|
||||
case meshtastic_AdminMessage_set_module_config_tag:
|
||||
LOG_DEBUG("Client set module config");
|
||||
#if !MESHTASTIC_EXCLUDE_BEACON
|
||||
// broadcast_send_as_node: remote admins may only set this to their own node ID.
|
||||
if (mp.from != 0 && r->set_module_config.which_payload_variant == meshtastic_ModuleConfig_mesh_beacon_tag) {
|
||||
auto &b = r->set_module_config.payload_variant.mesh_beacon;
|
||||
if (b.broadcast_send_as_node != 0 && b.broadcast_send_as_node != mp.from) {
|
||||
LOG_WARN("Beacon: rejecting broadcast_send_as_node 0x%08x from node 0x%08x (must match sender)",
|
||||
b.broadcast_send_as_node, mp.from);
|
||||
b.broadcast_send_as_node = moduleConfig.mesh_beacon.broadcast_send_as_node;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!handleSetModuleConfig(r->set_module_config)) {
|
||||
myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp);
|
||||
}
|
||||
@@ -1371,19 +1360,6 @@ bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
||||
if (beaconCfg.broadcast_interval_secs != 0 &&
|
||||
beaconCfg.broadcast_interval_secs < default_mesh_beacon_min_broadcast_interval_secs)
|
||||
beaconCfg.broadcast_interval_secs = default_mesh_beacon_min_broadcast_interval_secs;
|
||||
// Validate broadcast_on_preset against broadcast_on_region (or current region if unset).
|
||||
if (beaconCfg.has_broadcast_on_preset) {
|
||||
meshtastic_Config_LoRaConfig probe = config.lora;
|
||||
probe.use_preset = true;
|
||||
probe.modem_preset = beaconCfg.broadcast_on_preset;
|
||||
if (beaconCfg.broadcast_on_region != meshtastic_Config_LoRaConfig_RegionCode_UNSET)
|
||||
probe.region = beaconCfg.broadcast_on_region;
|
||||
if (!RadioInterface::validateConfigLora(probe)) {
|
||||
LOG_WARN("Beacon: broadcast_on_preset %d invalid for region, clearing", beaconCfg.broadcast_on_preset);
|
||||
beaconCfg.has_broadcast_on_preset = false;
|
||||
beaconCfg.has_broadcast_on_channel = false;
|
||||
}
|
||||
}
|
||||
// Validate broadcast_offer_preset against broadcast_offer_region (or current region if unset).
|
||||
if (beaconCfg.has_broadcast_offer_preset) {
|
||||
meshtastic_Config_LoRaConfig probe = config.lora;
|
||||
@@ -1404,8 +1380,8 @@ bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
||||
beaconCfg.broadcast_offer_region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
||||
}
|
||||
}
|
||||
// Validate each multi-target entry the same way as the single-target broadcast_on_* fields,
|
||||
// so a bad preset/region is cleared on write rather than relying on the runtime TX drop.
|
||||
// Validate each broadcast target so a bad preset/region is cleared on write rather than
|
||||
// relying on the runtime TX drop.
|
||||
for (pb_size_t i = 0; i < beaconCfg.broadcast_targets_count; i++) {
|
||||
auto &t = beaconCfg.broadcast_targets[i];
|
||||
// Region must be a known region code (UNSET = use running config at TX time).
|
||||
|
||||
Reference in new issue
Block a user