5#include <PubSubClient.h>
37 const char* mqtt_server,
39 const char* wifi_ssid,
42 uint16_t buffer_size);
56 void publish(
char*
topic,
char* msg,
unsigned int plength);
89 void setup_wifi(
const char wifi_ssid[],
const char wifi_pwd[]);
A class for managing MQTT communication.
Definition: mqtt-client.h:23
void setup_wifi(const char wifi_ssid[], const char wifi_pwd[])
Connects the ESP to the WiFi network using provided credentials. WiFi settings can be found in the ma...
Definition: mqtt-client.cpp:40
bool is_connected()
Checks if the MQTT client is connected.
Definition: mqtt-client.cpp:30
String get_mac()
Get the MAC address of the WiFi client.
Definition: mqtt-client.cpp:35
void reconnect()
Reconnects the MQTT client to the broker. It retries every 5 seconds until a connection is establishe...
Definition: mqtt-client.cpp:60
const char * topic
Definition: mqtt-client.h:74
PubSubClient client
Used to send MQTT commands.
Definition: mqtt-client.h:72
void publish(char *topic, char *msg, unsigned int plength)
Publishes a message on the specified MQTT topic.
Definition: mqtt-client.cpp:79
WiFiClient espClient
Used to establish the WiFi connection.
Definition: mqtt-client.h:71
void update()
Must be called frequently to allow the callback function to handle incoming messages....
Definition: mqtt-client.cpp:54
String dev_id
Definition: mqtt-client.h:73
void subscribe_callback(char *topic, byte *payload, unsigned int length)
Callback function for MQTT subscriptions, called when a message arrives. simply prints the message to...
Definition: mqtt-client.cpp:5
Definition: mqtt-client.h:18