zephyr_ha_mqtt_sample/src/mqtt_client.h

44 lines
1.0 KiB
C

#ifndef MQTT_CLIENT_H
#define MQTT_CLIENT_H
#define HA_MQTT_STR_MAX_LEN 48
#define UUID_MAX_LEN 40
#define BROKER_HOST_MAX_LEN 64
extern char broker_host[BROKER_HOST_MAX_LEN];
extern bool mqtt_running;
extern bool state;
extern bool state_changed;
extern char uuid[];
extern char name[];
extern char broker_host[];
#include <zephyr/net/mqtt.h>
#include <zephyr/kernel.h>
#ifdef __cplusplus
extern "C" {
#endif
int mqtt_client_init_all(void);
int ha_mqtt_start(void);
int ha_mqtt_stop(void);
int ha_publish_discovery_document(struct mqtt_client *client);
int subscribe(struct mqtt_client *client, const char *topic);
void mqtt_evt_handler(struct mqtt_client *client, const struct mqtt_evt *evt);
void mqtt_client_run_loop(void);
void build_topic(char *buf, size_t buflen, const char *fmt);
void clear_fds(void);
int wait(int timeout);
int publish(struct mqtt_client *client, enum mqtt_qos qos, const char *topic, const char *payload);
extern struct mqtt_client client_ctx;
#ifdef __cplusplus
}
#endif
#endif // MQTT_CLIENT_H