26 lines
714 B
C++
26 lines
714 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);
|
|
|
|
void reportLedState();
|
|
~MqttClient();
|
|
|
|
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;
|
|
std::string m_statusTopic;
|
|
esp_mqtt_client_handle_t m_client = nullptr;
|
|
};
|
|
#endif // __MQTTCLIENT_H__
|