feat:新增MQTT控制组件和自动告警系统
- 实现MQTT控制功能,处理水泵和灯光控制指令 - 新增土壤湿度和光照强度自动告警系统,阈值可配置 - 新建MQTT控制、自动告警和阈值管理相关文件 - 更新主应用,集成MQTT和自动控制功能 - 新增传感器数据与控制状态遥测上报 - 引入NVS和应用存储分区配置
This commit is contained in:
49
components/mqtt_control/include/mqtt_control.h
Normal file
49
components/mqtt_control/include/mqtt_control.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "mqtt_client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool has_mode;
|
||||
bool auto_mode;
|
||||
|
||||
bool has_thresholds;
|
||||
float soil_on_pct;
|
||||
float soil_off_pct;
|
||||
float light_on_lux;
|
||||
float light_off_lux;
|
||||
|
||||
bool has_pump;
|
||||
bool pump_on;
|
||||
|
||||
bool has_light;
|
||||
bool light_on;
|
||||
} mqtt_control_command_t;
|
||||
|
||||
typedef esp_err_t (*mqtt_control_command_handler_t)(const mqtt_control_command_t *cmd, void *user_ctx);
|
||||
|
||||
esp_err_t mqtt_control_start(void);
|
||||
esp_err_t mqtt_control_stop(void);
|
||||
|
||||
esp_err_t mqtt_control_register_command_handler(mqtt_control_command_handler_t handler, void *user_ctx);
|
||||
|
||||
bool mqtt_control_is_connected(void);
|
||||
|
||||
// Generic publish API for any topic.
|
||||
esp_err_t mqtt_control_publish(const char *topic,
|
||||
const char *payload,
|
||||
int qos,
|
||||
int retain);
|
||||
|
||||
// Publish telemetry payload to default sensor topic.
|
||||
esp_err_t mqtt_control_publish_sensor(const char *payload, int qos, int retain);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user