mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-21 17:20:01 +00:00
Remove 'else'; simpifies #5516
This commit is contained in:
parent
a3a077b427
commit
938d8fe5fd
@ -64,7 +64,7 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length)
|
|||||||
LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!", topic, length);
|
LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!", topic, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meshtastic_Channel ch = channels.getByName(e.channel_id);
|
const meshtastic_Channel &ch = channels.getByName(e.channel_id);
|
||||||
if (strcmp(e.gateway_id, owner.id) == 0) {
|
if (strcmp(e.gateway_id, owner.id) == 0) {
|
||||||
// Generate an implicit ACK towards ourselves (handled and processed only locally!) for this message.
|
// Generate an implicit ACK towards ourselves (handled and processed only locally!) for this message.
|
||||||
// We do this because packets are not rebroadcasted back into MQTT anymore and we assume that at least one node
|
// We do this because packets are not rebroadcasted back into MQTT anymore and we assume that at least one node
|
||||||
@ -75,6 +75,11 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length)
|
|||||||
LOG_INFO("Ignore downlink message we originally sent");
|
LOG_INFO("Ignore downlink message we originally sent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isFromUs(e.packet)) {
|
||||||
|
LOG_INFO("Ignore downlink message we originally sent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Find channel by channel_id and check downlink_enabled
|
// Find channel by channel_id and check downlink_enabled
|
||||||
if (!(strcmp(e.channel_id, "PKI") == 0 ||
|
if (!(strcmp(e.channel_id, "PKI") == 0 ||
|
||||||
(strcmp(e.channel_id, channels.getGlobalId(ch.index)) == 0 && ch.settings.downlink_enabled))) {
|
(strcmp(e.channel_id, channels.getGlobalId(ch.index)) == 0 && ch.settings.downlink_enabled))) {
|
||||||
@ -82,11 +87,6 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length)
|
|||||||
}
|
}
|
||||||
LOG_INFO("Received MQTT topic %s, len=%u", topic, length);
|
LOG_INFO("Received MQTT topic %s, len=%u", topic, length);
|
||||||
|
|
||||||
if (isFromUs(e.packet)) {
|
|
||||||
LOG_INFO("Ignore downlink message we originally sent");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UniquePacketPoolPacket p = packetPool.allocUniqueCopy(*e.packet);
|
UniquePacketPoolPacket p = packetPool.allocUniqueCopy(*e.packet);
|
||||||
p->via_mqtt = true; // Mark that the packet was received via MQTT
|
p->via_mqtt = true; // Mark that the packet was received via MQTT
|
||||||
|
|
||||||
@ -217,6 +217,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
|
|||||||
LOG_WARN("Empty MQTT payload received, topic %s!", topic);
|
LOG_WARN("Empty MQTT payload received, topic %s!", topic);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this is a json payload message by comparing the topic start
|
// check if this is a json payload message by comparing the topic start
|
||||||
if (moduleConfig.mqtt.json_enabled && (strncmp(topic, jsonTopic.c_str(), jsonTopic.length()) == 0)) {
|
if (moduleConfig.mqtt.json_enabled && (strncmp(topic, jsonTopic.c_str(), jsonTopic.length()) == 0)) {
|
||||||
// parse the channel name from the topic string
|
// parse the channel name from the topic string
|
||||||
@ -232,9 +233,10 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onReceiveJson(payload, length);
|
onReceiveJson(payload, length);
|
||||||
} else {
|
return;
|
||||||
onReceiveProto(topic, payload, length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onReceiveProto(topic, payload, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqttInit()
|
void mqttInit()
|
||||||
|
Loading…
Reference in New Issue
Block a user