convert mqtt_client from app to lib
This commit is contained in:
parent
495d415102
commit
6d7a8b99a7
6 changed files with 154 additions and 195 deletions
32
mqtt_client.h
Normal file
32
mqtt_client.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#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 */
|
||||
Loading…
Add table
Add a link
Reference in a new issue