完成初代的雏形设计
This commit is contained in:
59
components/mqtt_control/include/mqtt_control.h
Normal file
59
components/mqtt_control/include/mqtt_control.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#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 light_on_lux;
|
||||
float light_off_lux;
|
||||
float hot_on_temp_c;
|
||||
float hot_off_temp_c;
|
||||
float cool_on_temp_c;
|
||||
float cool_off_temp_c;
|
||||
float fan_on_hum_pct;
|
||||
float fan_off_hum_pct;
|
||||
|
||||
bool has_fan;
|
||||
bool fan_on;
|
||||
|
||||
bool has_light;
|
||||
bool light_on;
|
||||
|
||||
bool has_hot;
|
||||
bool hot_on;
|
||||
|
||||
bool has_cool;
|
||||
bool cool_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