#ifndef MQTT_INIT_H__
#define MQTT_INIT_H__
#include <time.h>
#include "mosquitto.h"
#include "cjson/cJSON.h"

//extern ThreadPool *pool;

#define MAX_SERVERS 10

typedef struct {
    struct mosquitto *mosq;
    char host[128];
    int port;
    char client_id[64];
} mqttclient;

extern mqttclient g_clients_t[MAX_SERVERS];

#define BROKER_PORT 1883
#define USERNAME "admin"    // 替换为你的用户名
#define PASSWORD "admin"       // 替换为你的密码
extern struct mosquitto *mosq;//创建客服端


extern int gPwmCount;  // 计数
extern int gmessage_type;//message消息值

int mqtt_init();//mqtt初始化
//void on_connect(struct mosquitto *mosq, void *obj, int rc);//回调函数
//void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message);//消息回调函数

int mqtt_cycle();//循环

//mqtt清理
void mqtt_clean();
#endif