50 lines
1021 B
C
50 lines
1021 B
C
#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
|