DualLedController/components/Communication/MqttClient.h
2024-06-01 23:47:21 +08:00

21 lines
582 B
C++

#ifndef __MQTTCLIENT_H__
#define __MQTTCLIENT_H__
#include <mqtt_client.h>
#include <string>
class MqttClient {
public:
static MqttClient *instance();
bool initialize(const std::string &username, const std::string &password);
protected:
static void eventHandler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
void onConnected(struct esp_mqtt_client *client);
void onSetStatus(const char *data, int size);
MqttClient() = default;
private:
std::string m_setStatusTopic;
};
#endif // __MQTTCLIENT_H__