mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 09:06:02 +00:00
Use the '+' wildcard for MQTT rather than '#', to subscribe only to topics one nesting level deep (#4528)
This commit is contained in:
parent
0850ad6c8d
commit
f99b81acf7
@ -376,12 +376,12 @@ void MQTT::sendSubscriptions()
|
||||
const auto &ch = channels.getByIndex(i);
|
||||
if (ch.settings.downlink_enabled) {
|
||||
hasDownlink = true;
|
||||
std::string topic = cryptTopic + channels.getGlobalId(i) + "/#";
|
||||
std::string topic = cryptTopic + channels.getGlobalId(i) + "/+";
|
||||
LOG_INFO("Subscribing to %s\n", topic.c_str());
|
||||
pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right?
|
||||
#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804
|
||||
if (moduleConfig.mqtt.json_enabled == true) {
|
||||
std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/#";
|
||||
std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/+";
|
||||
LOG_INFO("Subscribing to %s\n", topicDecoded.c_str());
|
||||
pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right?
|
||||
}
|
||||
@ -390,7 +390,7 @@ void MQTT::sendSubscriptions()
|
||||
}
|
||||
#if !MESHTASTIC_EXCLUDE_PKI
|
||||
if (hasDownlink) {
|
||||
std::string topic = cryptTopic + "PKI/#";
|
||||
std::string topic = cryptTopic + "PKI/+";
|
||||
LOG_INFO("Subscribing to %s\n", topic.c_str());
|
||||
pubSub.subscribe(topic.c_str(), 1);
|
||||
}
|
||||
@ -674,4 +674,4 @@ bool MQTT::isValidJsonEnvelope(JSONObject &json)
|
||||
(json["from"]->AsNumber() == nodeDB->getNodeNum()) && // only accept message if the "from" is us
|
||||
(json.find("type") != json.end()) && json["type"]->IsString() && // should specify a type
|
||||
(json.find("payload") != json.end()); // should have a payload
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user