Public Member Functions | |
PubSubClient (Socket &client) | |
PubSubClient (std::string ip, uint16_t port) | |
PubSubClient (std::string ip, uint16_t port, Socket &client) | |
PubSubClient (std::string ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Socket &client) | |
PubSubClient & | setServer (std::string ip, uint16_t port) |
Set server ip and Port of my MQTT server. More... | |
PubSubClient & | setCallback (MQTT_CALLBACK_SIGNATURE) |
Set the callback function for incoming data. More... | |
PubSubClient & | setClient (Socket &client) |
Set the socket, which we want to use for our MQTT communication. More... | |
bool | connect (const char *id) |
Connect to a MQTT server. More... | |
bool | connect (const char *id, const char *user, const char *pass) |
Connect to a MQTT server. More... | |
bool | connect (const char *id, const char *willTopic, uint8_t willQos, bool willRetain, const char *willMessage) |
Connect to a MQTT server. More... | |
bool | connect (const char *id, const char *user, const char *pass, const char *willTopic, uint8_t willQos, bool willRetain, const char *willMessage) |
Connect to a MQTT server. More... | |
bool | connect () |
Connect to a MQTT server with the with the previous settings. Note: do not call this function without settings, this will not work! For the very first connect process, use the connect function with parameters. More... | |
void | disconnect () |
Disconnect form MQTT server and close the socket. More... | |
bool | publish (const char *topic, const char *payload) |
Publish a MQTT message. More... | |
bool | publish (const char *topic, const char *payload, bool retained) |
Publish a MQTT message. More... | |
bool | publish (const char *topic, const uint8_t *payload, unsigned int plength) |
Publish a MQTT message. More... | |
bool | publish (const char *topic, const uint8_t *payload, unsigned int plength, bool retained) |
Publish a MQTT message. More... | |
bool | subscribe (const char *topic, bool ack=false) |
Subscribe a MQTT topic. More... | |
bool | unsubscribe (const char *topic, bool ack=false) |
Unsubscribe a MQTT topic. More... | |
bool | isSubscribeDone () |
Check the state of subscription. If there was received a subscription ACK, we return a true here. More... | |
bool | isUnsubscribeDone () |
Check the state of unsubscription. If there was received a unsubscription ACK, we return a true here. More... | |
bool | connected () |
Check the connection to the MQTT server. More... | |
int | state () |
Get the current MYTT state form the instance. More... | |
void | keepAliveChecker () |
This is a Timer called routine, which checks the PING_outstanding flag. This flag is set in this function. We send a Keep alive message to the server here. If there is a data in, or output, or we receive the MQTT ping request, the flag will be set to false by other functions. This function is called every MQTT_KEEPALIVE interval. If the flag is still true, we have a error with the connection. More... | |
void | timeoutChecker () |
This is a Timer called routine, which is called, when we reach the timeout. Used is this function for all ACK commands, which comes over MQTT. Notice, that the KeepAlivePing has his own Timer, to prevent conflicts. Basically, if this function is called, we have detected a MQTT timeout! More... | |
Friends | |
class | PubSubClientTask |
bool PubSubClient::connect | ( | const char * | id | ) |
Connect to a MQTT server.
[in] | Device | id to identify this device. |
bool PubSubClient::connect | ( | const char * | id, |
const char * | user, | ||
const char * | pass | ||
) |
Connect to a MQTT server.
[in] | Device | id to identify this device. [in] my user name. [in] my password. |
bool PubSubClient::connect | ( | const char * | id, |
const char * | willTopic, | ||
uint8_t | willQos, | ||
bool | willRetain, | ||
const char * | willMessage | ||
) |
Connect to a MQTT server.
[in] | Device | id to identify this device. [in] last will: topic name. [in] last will: qos-level. [in] last will: as retained message. [in] last will: payload. |
bool PubSubClient::connect | ( | const char * | id, |
const char * | user, | ||
const char * | pass, | ||
const char * | willTopic, | ||
uint8_t | willQos, | ||
bool | willRetain, | ||
const char * | willMessage | ||
) |
Connect to a MQTT server.
[in] | Device | id to identify this device. [in] my user name. [in] my password. [in] last will: topic name. [in] last will: qos-level. [in] last will: as retained message. [in] last will: payload. |
bool PubSubClient::connect | ( | ) |
Connect to a MQTT server with the with the previous settings. Note: do not call this function without settings, this will not work! For the very first connect process, use the connect function with parameters.
N/A |
bool PubSubClient::connected | ( | ) |
Check the connection to the MQTT server.
void PubSubClient::disconnect | ( | ) |
Disconnect form MQTT server and close the socket.
bool PubSubClient::isSubscribeDone | ( | ) |
Check the state of subscription. If there was received a subscription ACK, we return a true here.
bool PubSubClient::isUnsubscribeDone | ( | ) |
Check the state of unsubscription. If there was received a unsubscription ACK, we return a true here.
void PubSubClient::keepAliveChecker | ( | ) |
This is a Timer called routine, which checks the PING_outstanding flag. This flag is set in this function. We send a Keep alive message to the server here. If there is a data in, or output, or we receive the MQTT ping request, the flag will be set to false by other functions. This function is called every MQTT_KEEPALIVE interval. If the flag is still true, we have a error with the connection.
N/A. |
bool PubSubClient::publish | ( | const char * | topic, |
const char * | payload | ||
) |
Publish a MQTT message.
[in] | my | topic. [in] my payload. |
bool PubSubClient::publish | ( | const char * | topic, |
const char * | payload, | ||
bool | retained | ||
) |
Publish a MQTT message.
[in] | my | topic. [in] my payload. [in] is this a retained message (true/false) |
bool PubSubClient::publish | ( | const char * | topic, |
const uint8_t * | payload, | ||
unsigned int | plength | ||
) |
Publish a MQTT message.
[in] | my | topic. [in] my payload. [in] length of the message |
bool PubSubClient::publish | ( | const char * | topic, |
const uint8_t * | payload, | ||
unsigned int | plength, | ||
bool | retained | ||
) |
Publish a MQTT message.
[in] | my | topic. [in] my payload. [in] length of the message [in] is this a retained message (true/false) |
PubSubClient & PubSubClient::setCallback | ( | MQTT_CALLBACK_SIGNATURE | ) |
Set the callback function for incoming data.
[in] | callback | function |
PubSubClient & PubSubClient::setClient | ( | Socket & | client | ) |
Set the socket, which we want to use for our MQTT communication.
[in] | the | new socket instance |
PubSubClient & PubSubClient::setServer | ( | std::string | ip, |
uint16_t | port | ||
) |
Set server ip and Port of my MQTT server.
[in] | ip | of the distant MQTT server. [in] the port of the distant MQTT port. |
int PubSubClient::state | ( | ) |
Get the current MYTT state form the instance.
N/A. |
bool PubSubClient::subscribe | ( | const char * | topic, |
bool | ack = false |
||
) |
Subscribe a MQTT topic.
[in] | my | topic [in] qos of subscription |
void PubSubClient::timeoutChecker | ( | ) |
This is a Timer called routine, which is called, when we reach the timeout. Used is this function for all ACK commands, which comes over MQTT. Notice, that the KeepAlivePing has his own Timer, to prevent conflicts. Basically, if this function is called, we have detected a MQTT timeout!
N/A. |
bool PubSubClient::unsubscribe | ( | const char * | topic, |
bool | ack = false |
||
) |
Unsubscribe a MQTT topic.
[in] | my | topic [in] qos of unsubscription |