Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
ELClientMqtt Class Reference

#include <ELClientMqtt.h>

Collaboration diagram for ELClientMqtt:

Public Member Functions

 ELClientMqtt (ELClient *elc)
 Constructor for ELClientMqtt.
 
void setup (void)
 Setup mqtt.
 
void subscribe (const char *topic, uint8_t qos=0)
 Subscribe to MQTT topic.
 
void subscribe (const __FlashStringHelper *topic, uint8_t qos=0)
 Subscribe to MQTT topic.
 
void publish (const char *topic, const uint8_t *data, const uint16_t len, uint8_t qos=0, uint8_t retain=0)
 Subscribe to MQTT topic.
 
void publish (const char *topic, const char *data, uint8_t qos=0, uint8_t retain=0)
 Subscribe to MQTT topic.
 
void publish (const __FlashStringHelper *topic, const __FlashStringHelper *data, const uint16_t len, uint8_t qos=0, uint8_t retain=0)
 Subscribe to MQTT topic.
 
void publish (const char *topic, const __FlashStringHelper *data, const uint16_t len, uint8_t qos=0, uint8_t retain=0)
 Subscribe to MQTT topic.
 
void publish (const __FlashStringHelper *topic, const uint8_t *data, const uint16_t len, uint8_t qos=0, uint8_t retain=0)
 Subscribe to MQTT topic.
 
void lwt (const char *topic, const char *message, uint8_t qos=0, uint8_t retain=0)
 Set MQTT last will.
 
void lwt (const __FlashStringHelper *topic, const __FlashStringHelper *message, uint8_t qos=0, uint8_t retain=0)
 Set MQTT last will.
 

Data Fields

FP< void, void * > connectedCb
 
FP< void, void * > disconnectedCb
 
FP< void, void * > publishedCb
 
FP< void, void * > dataCb
 

Detailed Description

Definition at line 22 of file ELClientMqtt.h.

Constructor & Destructor Documentation

◆ ELClientMqtt()

ELClientMqtt::ELClientMqtt ( ELClient elc)

Constructor for ELClientMqtt.

ELClientMqtt(ELClient* elc)

Example

Definition at line 20 of file ELClientMqtt.cpp.

Member Function Documentation

◆ lwt() [1/2]

void ELClientMqtt::lwt ( const __FlashStringHelper *  topic,
const __FlashStringHelper *  message,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Set MQTT last will.

lwt(const __FlashStringHelper* topic, const __FlashStringHelper* message, uint8_t qos, uint8_t retain)

Sends the "last will" to the ESP with the topic and message stored in program memory

Parameters
topicLast will topic name
messageLast will message
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
no example code yet

Definition at line 94 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ lwt() [2/2]

void ELClientMqtt::lwt ( const char *  topic,
const char *  message,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Set MQTT last will.

lwt(const char* topic, const char* message, uint8_t qos, uint8_t retain)

Sends the "last will" to the ESP.

Parameters
topicLast will topic name
messageLast will message
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
Serial.println("ARDUINO: setup mqtt lwt");
mqtt.lwt("/lwt", "offline", 0, 0); //or mqtt.lwt("/lwt", "offline");
ESP esp & Serial
Definition demo.ino:9

Definition at line 68 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ publish() [1/5]

void ELClientMqtt::publish ( const __FlashStringHelper *  topic,
const __FlashStringHelper *  data,
const uint16_t  len,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Subscribe to MQTT topic.

publish(const __FlashStringHelper* topic, const __FlashStringHelper* data, const uint16_t len, uint8_t qos, uint8_t retain)

Sends the MQTT subscription request to the ESP with the topic and data stored in program memory

Parameters
topicTopic name
dataPointer to data buffer
lenSize of data buffer
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
no example code yet

Definition at line 230 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ publish() [2/5]

void ELClientMqtt::publish ( const __FlashStringHelper *  topic,
const uint8_t *  data,
const uint16_t  len,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Subscribe to MQTT topic.

publish(const __FlashStringHelper* topic, const uint8_t* data, const uint16_t len, uint8_t qos, uint8_t retain)

Sends the MQTT subscription request to the ESP with the topic stored in program memory

Parameters
topicTopic name
dataPointer to data buffer
lenSize of data buffer
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
no example code yet

Definition at line 292 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ publish() [3/5]

void ELClientMqtt::publish ( const char *  topic,
const __FlashStringHelper *  data,
const uint16_t  len,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Subscribe to MQTT topic.

ELClientMqtt::publish(const char* topic, const __FlashStringHelper* data, const uint16_t len, uint8_t qos, uint8_t retain)

Sends the MQTT subscription request to the ESP with the data stored in program memory

Parameters
topicTopic name
dataPointer to data buffer
lenSize of data buffer
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
no example code yet

Definition at line 261 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ publish() [4/5]

void ELClientMqtt::publish ( const char *  topic,
const char *  data,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Subscribe to MQTT topic.

publish(const char* topic, const char* data, uint8_t qos, uint8_t retain)

Sends the MQTT subscription request to the ESP. Data must be null-terminated

Parameters
topicTopic name
dataPointer to data buffer
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
char buf[12];
itoa(count++, buf, 10);
mqtt.publish("/esp-link/1", buf);
itoa(count+99, buf, 10);
mqtt.publish("/hello/world/arduino", buf);

Definition at line 206 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ publish() [5/5]

void ELClientMqtt::publish ( const char *  topic,
const uint8_t *  data,
const uint16_t  len,
uint8_t  qos = 0,
uint8_t  retain = 0 
)

Subscribe to MQTT topic.

publish(const char* topic, const uint8_t* data, const uint16_t len, uint8_t qos, uint8_t retain)

Sends the MQTT subscription request to the ESP

Parameters
topicTopic name
dataPointer to data buffer
lenSize of data buffer
qos(optional) Requested qos level, default 0
retain(optional) Requested retain level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
char buf[12];
itoa(count++, buf, 10);
mqtt.publish("/esp-link/1", buf);
itoa(count+99, buf, 10);
mqtt.publish("/hello/world/arduino", buf, 12);

Definition at line 173 of file ELClientMqtt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup()

void ELClientMqtt::setup ( void  )

Setup mqtt.

setup(void)

Send callback functions for MQTT events to the ESP

Example
mqtt.connectedCb.attach(mqttConnected);
mqtt.disconnectedCb.attach(mqttDisconnected);
mqtt.publishedCb.attach(mqttPublished);
mqtt.dataCb.attach(mqttData);
mqtt.setup();
void mqttConnected(void *response)
Definition mqtt.ino:39
void mqttData(void *response)
Definition mqtt.ino:55
void mqttPublished(void *response)
Definition mqtt.ino:67
void mqttDisconnected(void *response)
Definition mqtt.ino:49

Definition at line 34 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ subscribe() [1/2]

void ELClientMqtt::subscribe ( const __FlashStringHelper *  topic,
uint8_t  qos = 0 
)

Subscribe to MQTT topic.

subscribe(const __FlashStringHelper* topic, uint8_t qos)

Sends the MQTT subscription request to the ESP with the topic and message stored in program memory

Parameters
topicTopic name
qos(optional) Requested qos level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
no example code yet

Definition at line 141 of file ELClientMqtt.cpp.

Here is the call graph for this function:

◆ subscribe() [2/2]

void ELClientMqtt::subscribe ( const char *  topic,
uint8_t  qos = 0 
)

Subscribe to MQTT topic.

subscribe(const char* topic, uint8_t qos)

Sends the MQTT subscription request to the ESP

Parameters
topicTopic name
qos(optional) Requested qos level, default 0
Warning
At the moment only qos level 0 is implemented and supported!
Example
mqtt.subscribe("/esp-link/1");
mqtt.subscribe("/hello/world/#");

Definition at line 121 of file ELClientMqtt.cpp.

Here is the call graph for this function:

Field Documentation

◆ connectedCb

FP<void, void*> ELClientMqtt::connectedCb

callback with no args when MQTT is connected

Definition at line 34 of file ELClientMqtt.h.

◆ dataCb

FP<void, void*> ELClientMqtt::dataCb

callback when a message is received, called with two arguments: the topic and the message (max ~110 bytes for both)

Definition at line 37 of file ELClientMqtt.h.

◆ disconnectedCb

FP<void, void*> ELClientMqtt::disconnectedCb

callback with no args when MQTT is disconnected

Definition at line 35 of file ELClientMqtt.h.

◆ publishedCb

FP<void, void*> ELClientMqtt::publishedCb

not yet implemented

Definition at line 36 of file ELClientMqtt.h.


The documentation for this class was generated from the following files: