diff --git a/src/network/XD0MQTT.cpp b/src/network/XD0MQTT.cpp index 9773e99..65e2400 100644 --- a/src/network/XD0MQTT.cpp +++ b/src/network/XD0MQTT.cpp @@ -60,9 +60,16 @@ esp_err_t XD0MQTT::mqtt_event_handler_cb(esp_mqtt_event_handle_t event) ESP_LOGI(TAG, "TOPIC=%.*s\r\n", event->topic_len, event->topic); ESP_LOGI(TAG, "DATA=%.*s\r\n", event->data_len, event->data); for (const auto &subscription : subscriptions_) { + // literal match if (strcmp(event->topic, subscription.topic) == 0) { subscription.cb(event->topic, event->data); + // '#' wildcard + } else if (subscription.topic[strlen(subscription.topic)-1] == '#'){ + if (strncmp(event->topic, subscription.topic, strlen(subscription.topic)-1) == 0) { + subscription.cb(event->topic, event->data); + } } + // ToDo: '+' wildcard } break; case MQTT_EVENT_ERROR: