32 lines
936 B
C
32 lines
936 B
C
#ifndef MQTT_CLIENT_H
|
|
#define MQTT_CLIENT_H
|
|
|
|
// #include "pico/cyw43_arch.h"
|
|
#include "lwip/apps/mqtt.h"
|
|
|
|
#ifndef MQTT_SERVER
|
|
#error Need to define MQTT_SERVER
|
|
#endif
|
|
|
|
typedef struct {
|
|
mqtt_client_t* mqtt_client_inst;
|
|
struct mqtt_connect_client_info_t mqtt_client_info;
|
|
char data[MQTT_OUTPUT_RINGBUF_SIZE];
|
|
char topic[100];
|
|
uint32_t len;
|
|
ip_addr_t mqtt_server_address;
|
|
bool connect_done;
|
|
int subscribe_count;
|
|
bool stop_client;
|
|
} MQTT_CLIENT_DATA_T;
|
|
|
|
typedef struct {
|
|
char topic[201]; // max 200 chars + null terminator
|
|
char device_name[51]; // max 50 chars + null terminator
|
|
MQTT_CLIENT_DATA_T state;
|
|
} mqtt_client_config;
|
|
|
|
void mqtt_client_init(mqtt_client_config *config, const char *topic, const char *device_name);
|
|
void mqtt_client_pub_message(mqtt_client_config *config, const char *message);
|
|
void mqtt_client_do_network_stuff(mqtt_client_config *config);
|
|
#endif /* MQTT_CLIENT_H */
|