添加农业环境模块,集成 MQTT 客户端功能,支持配置参数和数据发布

This commit is contained in:
Wang Beihong
2026-04-22 01:21:26 +08:00
parent ffdb7065e3
commit 811b47d274
8 changed files with 425 additions and 38 deletions

View File

@@ -0,0 +1,25 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/* 启动 MQTT 客户端连接。 */
esp_err_t agri_env_mqtt_start(void);
/* 停止 MQTT 客户端连接并释放资源。 */
esp_err_t agri_env_mqtt_stop(void);
/* 查询 MQTT 当前是否已连接。 */
bool agri_env_mqtt_is_connected(void);
/* 发布指定的 JSON 载荷到指定主题。 */
esp_err_t agri_env_mqtt_publish(const char *topic, const char *payload, int qos, int retain);
/* 发布固定 MQTT-only 心跳载荷到指定主题。 */
esp_err_t agri_env_mqtt_publish_latest(const char *topic, int qos, int retain);
#ifdef __cplusplus
}
#endif