diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index dd547a6f1a0..e9444cffa97 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -43,7 +43,8 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas } if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { if (p->id != 0) { - if (config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE) { + if (config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE && + !(p->via_mqtt && config.lora.ignore_mqtt)) { meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it tosend->hop_limit--; // bump down the hop count @@ -53,7 +54,7 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas // We are careful not to call our hooked version of send() - because we don't want to check this again Router::send(tosend); } else { - LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n"); + LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute or packet came via MQTT with ignore MQTT set\n"); } } else { LOG_DEBUG("Ignoring a simple (0 id) broadcast\n"); diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 2cfb4843cdf..c57e11f36e6 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -92,7 +92,7 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp) "Received telemetry response. Skip sending our NodeInfo because this potentially a Repeater which will ignore our " "request for its NodeInfo.\n"); } else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user && - nodeInfoModule) { + nodeInfoModule && !(mp->via_mqtt && config.lora.ignore_mqtt)) { LOG_INFO("Heard a node on channel %d we don't know, sending NodeInfo and asking for a response.\n", mp->channel); nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel); } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index cf576e94fe7..f02baaa7c2b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -243,7 +243,7 @@ void NodeDB::installDefaultConfig() config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET; config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; config.lora.hop_limit = HOP_RELIABLE; - config.lora.ignore_mqtt = false; + config.lora.ignore_mqtt = true; #ifdef PIN_GPS_EN config.position.gps_en_gpio = PIN_GPS_EN; #endif diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 3141d986bb3..c002132ac3c 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -489,7 +489,18 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) { // assert(radioConfig.has_preferences); - bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from) || (config.lora.ignore_mqtt && p->via_mqtt); + bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from); + + if (p->via_mqtt && config.lora.ignore_mqtt) { + bool allow_mqtt = false; + // Check if this packet was received via MQTT on a channel we have downlink enabled (in that case packet is decoded here) + if (moduleConfig.mqtt.enabled && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { + meshtastic_Channel channel = channels.getByIndex(p->channel); + if (channel.has_settings && channel.settings.downlink_enabled) + allow_mqtt = true; + } + ignore |= !allow_mqtt; + } if (ignore) { LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list or came via MQTT\n", p->from); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 09158646236..26b2407ab93 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -452,9 +452,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) { config.lora.tx_enabled = true; initRegion(); - if (myRegion->dutyCycle < 100) { - config.lora.ignore_mqtt = true; // Ignore MQTT by default if region has a duty cycle limit - } + config.lora.ignore_mqtt = true; // Ignore MQTT by default if (strcmp(moduleConfig.mqtt.root, default_mqtt_root) == 0) { sprintf(moduleConfig.mqtt.root, "%s/%s", default_mqtt_root, myRegion->name); changes = SEGMENT_CONFIG | SEGMENT_MODULECONFIG;