#ifndef _MYMQTT_H #define _MYMQTT_H #include #include "config.h" class MyMQTT { public: MyMQTT(void); void connect(void); void subscribe(void); bool connected(void); void publish(char* topic, char* payload); void publish(char* topic, String payload); void onMqttConnect(bool sessionPresent); void onMqttDisconnect(AsyncMqttClientDisconnectReason reason); void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total); // static void onMqttMessageWrapper(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total); static void onMqttConnectWrapper(bool sessionPresent); static void onMqttDisconnectWrapper(AsyncMqttClientDisconnectReason reason); private: const char* host; const uint32_t port; const char* endpoint; const char* username; const char* password; AsyncMqttClient mqttClient; static void cTaskWrapper(void*); void reconnectTask(void*); TaskHandle_t mqttTaskHandle; // static MyMQTT* mqtt_ptr; }; static MyMQTT* mqtt_ptr = nullptr; #endif /* _MYMQTT_H */