// SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include #include typedef std::function OnMessageCallback; struct cb_filter_t { std::string topic; uint8_t qos; OnMessageCallback cb; }; class MqttSubscribeParser { public: void register_callback(const std::string& topic, uint8_t qos, const OnMessageCallback& cb); void unregister_callback(const std::string& topic); void handle_message(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len); std::vector get_callbacks(); private: int mosquitto_topic_matches_sub(const char* sub, const char* topic, bool* result); std::vector _callbacks; enum mosq_err_t { MOSQ_ERR_SUCCESS = 0, MOSQ_ERR_INVAL = 3, }; };