From b25797e1b3d19ceec67493f801332ec53c4071cc Mon Sep 17 00:00:00 2001 From: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:01:15 -0800 Subject: [PATCH] Discard everything if downlink isn't on (#8578) --- src/mqtt/MQTT.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 33887557f..40d03de63 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -59,7 +59,13 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length) LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!", topic, length); return; } + const meshtastic_Channel &ch = channels.getByName(e.channel_id); + // Find channel by channel_id and check downlink_enabled + if (!(strcmp(e.channel_id, "PKI") == 0 || + (strcmp(e.channel_id, channels.getGlobalId(ch.index)) == 0 && ch.settings.downlink_enabled))) { + return; + } // Generate node ID from nodenum for comparison std::string nodeId = nodeDB->getNodeId(); if (strcmp(e.gateway_id, nodeId.c_str()) == 0) { @@ -77,11 +83,6 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length) return; } - // Find channel by channel_id and check downlink_enabled - if (!(strcmp(e.channel_id, "PKI") == 0 || - (strcmp(e.channel_id, channels.getGlobalId(ch.index)) == 0 && ch.settings.downlink_enabled))) { - return; - } LOG_INFO("Received MQTT topic %s, len=%u", topic, length); if (e.packet->hop_limit > HOP_MAX || e.packet->hop_start > HOP_MAX) { LOG_INFO("Invalid hop_limit(%u) or hop_start(%u)", e.packet->hop_limit, e.packet->hop_start);