From 36dbeacaa1f95dd76954186a6171055895577aef Mon Sep 17 00:00:00 2001 From: mbench757 <36611650+mbench757@users.noreply.github.com> Date: Sat, 12 Mar 2022 17:03:20 -0600 Subject: [PATCH] Enable shared subscription for MQTTv5 I've tested this on an ESP32 C3 with mosquitto mqtt broker. This allows shared subscription topic to find the correct callback for processing. --- src/EspMQTTClient.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/EspMQTTClient.cpp b/src/EspMQTTClient.cpp index 70347fe..2dd40a6 100644 --- a/src/EspMQTTClient.cpp +++ b/src/EspMQTTClient.cpp @@ -692,6 +692,14 @@ bool EspMQTTClient::mqttTopicMatch(const String &topic1, const String &topic2) if(topic2.substring(t1a.length(), topic2.length()-t1b.length()).indexOf('/') == -1) return true; } + } + else if ((i = topic1.indexOf('$')) >= 0) + { + // shared subscription for MQTTv5 + if (topic1.startsWith("$share")) + { + return topic1.endsWith(topic2); + } } else {