shuichan_old/V1.2/STM32F103_App1/HardWare/WIFI/mqtt_client.h

27 lines
1.2 KiB
C
Raw Normal View History

#ifndef MQTT_CLIENT_H
#define MQTT_CLIENT_H
#include <stdint.h>
/* 精简版 MQTT 3.1.1 客户端:跑在 ESP-01S TCP 透传之上。
* 4WIFI和4G V3.4 WIFI无回弹HARDWARE/ML302/mqtt.c
* 6KB RAM
* U2_CopyBuff */
#define MQTT_KEEPALIVE_S 60 /* CONNECT 报文中的 keepalive */
/* PINGREQ 发出后置1收到 PINGRESP 清0net_wifi 据此判断链路存活 */
extern volatile uint8_t g_mqttc_ping_outstanding;
void mqttc_init(const char *client_id, const char *user, const char *pass);
int mqttc_connect(void); /* 发 CONNECT 等 CONNACK, 0=成功 */
int mqttc_subscribe(const char *topic); /* 发 SUBSCRIBE(QoS0) 等 SUBACK, 0=成功 */
int mqttc_publish(const char *topic, const char *payload); /* QoS0 发布, 0=成功 */
void mqttc_ping(void); /* 发 PINGREQ */
/* 从共享接收缓冲解析一条完整 MQTT 报文(粘包/半包安全)。
* 1=(), 0=, -1=( CLOSED) */
int mqttc_process(void);
#endif /* MQTT_CLIENT_H */