2024-04-03 07:04:55 +07:00
|
|
|
#ifndef _AG_MQTT_CLIENT_H_
|
|
|
|
|
#define _AG_MQTT_CLIENT_H_
|
|
|
|
|
|
|
|
|
|
#include "mqtt_client.h"
|
2024-04-03 21:26:04 +07:00
|
|
|
#include "Main/PrintLog.h"
|
2024-04-03 07:04:55 +07:00
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
2024-04-03 21:26:04 +07:00
|
|
|
class MqttClient: public PrintLog {
|
2024-04-03 07:04:55 +07:00
|
|
|
private:
|
|
|
|
|
bool isBegin = false;
|
|
|
|
|
String uri;
|
|
|
|
|
esp_mqtt_client_handle_t client;
|
|
|
|
|
bool connected = false;
|
|
|
|
|
int connectionFailedCount = 0;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
MqttClient(Stream &debugLog);
|
|
|
|
|
~MqttClient();
|
|
|
|
|
|
|
|
|
|
bool begin(String uri);
|
|
|
|
|
void end(void);
|
|
|
|
|
void _updateConnected(bool connected);
|
|
|
|
|
bool publish(String &topic, String &payload);
|
|
|
|
|
bool isCurrentUri(String &uri);
|
|
|
|
|
bool isConnected(void);
|
|
|
|
|
int getConnectionFailedCount(void);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /** _AG_MQTT_CLIENT_H_ */
|