From bfcf017625d537144b8511d69d5aabd66d01e886 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 25 Apr 2026 09:32:23 -0700 Subject: [PATCH] refactor(mqtt): update default TX packet settings and documentation Changed the default setting for TX packets from disabled to 'advert' across multiple files, including documentation and example implementations. This aligns the behavior of the MQTT bridge with the new default preferences, ensuring that only the node's own advert packets are uplinked by default. Updated relevant comments and documentation to reflect these changes. --- MQTT_IMPLEMENTATION.md | 2 +- docs/cli_commands.md | 2 +- examples/simple_repeater/MyMesh.cpp | 2 +- examples/simple_room_server/MyMesh.cpp | 2 +- src/helpers/CommonCLI.cpp | 6 ++---- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/MQTT_IMPLEMENTATION.md b/MQTT_IMPLEMENTATION.md index e4c0d3386..f66f38880 100644 --- a/MQTT_IMPLEMENTATION.md +++ b/MQTT_IMPLEMENTATION.md @@ -195,7 +195,7 @@ The MQTT bridge comes with the following defaults for fresh installs: - **Packet Messages**: Enabled - **Raw Messages**: Disabled - **RX Packets**: Enabled (uplink received packets) -- **TX Packets**: Disabled (`off` — set to `on` or `advert` to enable) +- **TX Packets**: `advert` by default (uplink this node's own adverts; set to `on` for all TX or `off` to disable) - **Status Interval**: 5 minutes (300000 ms) - **Slot 1**: `analyzer-us` - **Slot 2**: `analyzer-eu` diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 757c959ed..3b778d6ab 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -1020,7 +1020,7 @@ region save - `advert`: uplink only this node's own advert packets (self-originated advertisements only — forwarded adverts from other nodes are filtered out) - `off`: disable TX packet uplinking -**Default:** `off` +**Default:** `advert` > **Note:** `mqtt.rx` and `mqtt.tx` take effect immediately — no restart required. Both can be enabled simultaneously. diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index f22c6a7ac..1d65ba62a 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -971,7 +971,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc _prefs.mqtt_status_enabled = 1; // enabled _prefs.mqtt_packets_enabled = 1; // enabled _prefs.mqtt_raw_enabled = 0; // disabled - _prefs.mqtt_tx_enabled = 0; // disabled (RX only for now) + _prefs.mqtt_tx_enabled = 2; // advert: own adverts only (matches MQTTPrefs default) _prefs.mqtt_rx_enabled = 1; // RX packets enabled by default _prefs.mqtt_status_interval = 300000; // 5 minutes diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index 4ecdf2905..3497b8e3e 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -688,7 +688,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc _prefs.mqtt_status_enabled = 1; // enabled _prefs.mqtt_packets_enabled = 1; // enabled _prefs.mqtt_raw_enabled = 0; // disabled - _prefs.mqtt_tx_enabled = 0; // disabled (RX only for now) + _prefs.mqtt_tx_enabled = 2; // advert: own adverts only (matches MQTTPrefs default) _prefs.mqtt_rx_enabled = 1; // RX packets enabled by default _prefs.mqtt_status_interval = 300000; // 5 minutes diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 899317fdb..0853d82aa 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -125,9 +125,7 @@ void CommonCLI::loadPrefs(FILESYSTEM* fs) { syncMQTTPrefsToNodePrefs(); // For MQTT bridge, migrate bridge.source to RX (logRx) only on fresh installs or upgrades - // This ensures new users get the correct default, but respects existing user choices - // MQTT bridge with TX requires mqtt.tx to be enabled (disabled by default), - // so RX is the sensible default for MQTT bridge installations + // so legacy "tx" is not the default. mqtt.rx / mqtt.tx are separate (fresh default: advert for TX) if ((is_fresh_install || is_upgrade) && _prefs->bridge_pkt_src == 0) { MESH_DEBUG_PRINTLN("MQTT Bridge: Migrating bridge.source from tx to rx (MQTT bridge default)"); _prefs->bridge_pkt_src = 1; // Set to RX (logRx) @@ -364,7 +362,7 @@ static void setMQTTPrefsDefaults(MQTTPrefs* prefs) { prefs->mqtt_status_enabled = 1; // enabled by default prefs->mqtt_packets_enabled = 1; // enabled by default prefs->mqtt_raw_enabled = 0; // disabled by default - prefs->mqtt_tx_enabled = 0; // disabled by default + prefs->mqtt_tx_enabled = 2; // advert: own adverts only, by default prefs->mqtt_rx_enabled = 1; // RX packets enabled by default prefs->mqtt_status_interval = 300000; // 5 minutes default // Slot presets: analyzer-us and analyzer-eu enabled by default, rest = none