/// © MiroZ 2024

#ifndef __MQTT_T__
#define __MQTT_T__

#include <stdint.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <functional>
#include "AppIF.h"

#include "mqtt_client.h"

extern const uint8_t server_cert[] asm("_binary_eventgrid_azure_pem_start");
extern const uint8_t client_cert[] asm("_binary_client1_authn_ID_pem_start");
extern const uint8_t client_key[] asm("_binary_client1_authn_ID_key_start");

using namespace std::placeholders;

class Mqtt
{
protected:
    WiFiClientSecure *m_esp_client;
    PubSubClient *m_mqtt_client;
    void callback(char* topic, uint8_t * payload, uint32_t length);

	TaskHandle_t m_task = nullptr;
	void task();
    AppIF & m_app_if;

public:
    Mqtt(AppIF & app_if);
    void start();

};

#endif