This class provides a client for doing simple publish and subscribe messaging with a server that supports MQTT. More...
#include <PubSubClient.h>
Public Member Functions | |
| PubSubClient () | |
| Creates an uninitialised client instance. | |
| PubSubClient (Client &client) | |
| Creates a partially initialised client instance. | |
| PubSubClient (IPAddress addr, uint16_t port, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (IPAddress addr, uint16_t port, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| PubSubClient (IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| PubSubClient (uint8_t *ip, uint16_t port, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (uint8_t *ip, uint16_t port, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| PubSubClient (uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| PubSubClient (const char *domain, uint16_t port, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (const char *domain, uint16_t port, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| PubSubClient (const char *domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client) | |
| Creates a fully configured client instance. | |
| PubSubClient (const char *domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client &client, Stream &stream) | |
| Creates a fully configured client instance. | |
| ~PubSubClient () | |
| Destructor for the PubSubClient class. | |
| PubSubClient & | setServer (IPAddress ip, uint16_t port) |
| Sets the server details. | |
| PubSubClient & | setServer (uint8_t *ip, uint16_t port) |
| Sets the server details. | |
| PubSubClient & | setServer (const char *domain, uint16_t port) |
| Sets the server details. | |
| PubSubClient & | setCallback (MQTT_CALLBACK_SIGNATURE) |
| Sets the message callback function. | |
| PubSubClient & | setClient (Client &client) |
| Sets the network client instance to use. | |
| PubSubClient & | setStream (Stream &stream) |
| Sets the stream to write received messages to. | |
| PubSubClient & | setKeepAlive (uint16_t keepAlive) |
| Sets the keep alive interval used by the client. This value should only be changed when the client is not connected. Set keepAlive to zero (0) to turn off the keep alive mechanism. | |
| PubSubClient & | setSocketTimeout (uint16_t timeout) |
| Sets the socket timeout used by the client. This determines how long the client will wait for incoming data when it expects data to arrive - for example, whilst it is in the middle of reading a MQTT packet. | |
| bool | setBufferSize (size_t size) |
| Sets the size, in bytes, of the internal send and receive buffer. This must be large enough to contain the full MQTT packet. When sending or receiving messages, the packet will contain the full topic string, the payload data, and a small number of header bytes. | |
| size_t | getBufferSize () |
| Gets the current size of the internal buffer. | |
| bool | connect (const char *id) |
| Connects the client using a clean session without username and password. | |
| bool | connect (const char *id, const char *user, const char *pass) |
| Connects the client using a clean session with username and password. | |
| bool | connect (const char *id, const char *willTopic, uint8_t willQos, bool willRetain, const char *willMessage) |
| Connects the client using a clean session and will. | |
| bool | connect (const char *id, const char *user, const char *pass, const char *willTopic, uint8_t willQos, bool willRetain, const char *willMessage) |
| Connects the client using a clean session with username, password and will. | |
| bool | connect (const char *id, const char *user, const char *pass, const char *willTopic, uint8_t willQos, bool willRetain, const char *willMessage, bool cleanSession) |
| Connects the client with all possible parameters (user, password, will and session). | |
| void | disconnect () |
| Disconnects the client. | |
| bool | publish (const char *topic, const char *payload) |
| Publishes a non retained message to the specified topic using QoS 0. | |
| bool | publish (const char *topic, const char *payload, bool retained) |
| Publishes a message to the specified topic using QoS 0. | |
| bool | publish (const char *topic, const char *payload, uint8_t qos, bool retained) |
| Publishes a message to the specified topic. | |
| bool | publish (const __FlashStringHelper *topic, const char *payload, uint8_t qos, bool retained) |
| Publishes a message to the specified topic. | |
| bool | publish (const __FlashStringHelper *topic, const __FlashStringHelper *payload, uint8_t qos, bool retained) |
| Publishes a message from __FlashStringHelper to the specified topic from __FlashStringHelper. | |
| bool | publish (const char *topic, const uint8_t *payload, size_t plength) |
| Publishes a non retained message to the specified topic using QoS 0. | |
| bool | publish (const char *topic, const uint8_t *payload, size_t plength, bool retained) |
| Publishes a message to the specified topic using QoS 0. | |
| bool | publish (const char *topic, const uint8_t *payload, size_t plength, uint8_t qos, bool retained) |
| Publishes a message to the specified topic. | |
| bool | publish (const __FlashStringHelper *topic, const uint8_t *payload, size_t plength, uint8_t qos, bool retained) |
| Publishes a message to the specified topic. | |
| bool | publish_P (const char *topic, PGM_P payload, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic using QoS 0. | |
| bool | publish_P (const char *topic, PGM_P payload, uint8_t qos, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic. | |
| bool | publish_P (const __FlashStringHelper *topic, PGM_P payload, uint8_t qos, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic. | |
| bool | publish_P (const char *topic, const uint8_t *payload, size_t plength, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic using QoS 0. | |
| bool | publish_P (const char *topic, const uint8_t *payload, size_t plength, uint8_t qos, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic. | |
| bool | publish_P (const __FlashStringHelper *topic, const uint8_t *payload, size_t plength, uint8_t qos, bool retained) |
| Publishes a message stored in PROGMEM to the specified topic. | |
| bool | beginPublish (const char *topic, size_t plength, bool retained) |
| Start to publish a message using QoS 0. This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time. | |
| bool | beginPublish (const char *topic, size_t plength, uint8_t qos, bool retained) |
| Start to publish a message. This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time. | |
| bool | beginPublish (const __FlashStringHelper *topic, size_t plength, uint8_t qos, bool retained) |
| Start to publish a message using a topic from __FlashStringHelper F(). This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time. | |
| bool | beginPublish_P (PGM_P topic, size_t plength, uint8_t qos, bool retained) |
| Start to publish a message using a topic in PROGMEM. This API: beginPublish_P(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time. | |
| bool | endPublish () |
| Finish sending a message that was started with a call to beginPublish. | |
| virtual size_t | write (uint8_t data) |
| Writes a single byte as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish(). | |
| virtual size_t | write (const uint8_t *buf, size_t size) |
| Writes an array of bytes as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish(). | |
| size_t | write_P (PGM_P string) |
| Writes a string in PROGMEM as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish(). | |
| size_t | write_P (const uint8_t *buf, size_t size) |
| Writes an array of progmem bytes as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish(). | |
| bool | subscribe (const char *topic) |
| Subscribes to messages published to the specified topic using QoS 0. | |
| bool | subscribe (const __FlashStringHelper *topic) |
| Subscribes to messages published to the specified topic from __FlashStringHelper using QoS 0. | |
| bool | subscribe_P (PGM_P topic) |
| Subscribes to messages published to the specified topic in PROGMEM using QoS 0. | |
| bool | subscribe (const char *topic, uint8_t qos) |
| Subscribes to messages published to the specified topic. | |
| bool | subscribe (const __FlashStringHelper *topic, uint8_t qos) |
| Subscribes to messages published to the specified topic from __FlashStringHelper. | |
| bool | subscribe_P (PGM_P topic, uint8_t qos) |
| Subscribes to messages published to the specified topic in PROGMEM. | |
| bool | unsubscribe (const char *topic) |
| Unsubscribes from the specified topic. | |
| bool | unsubscribe (const __FlashStringHelper *topic) |
| Unsubscribes from the specified topic from __FlashStringHelper. | |
| bool | unsubscribe_P (PGM_P topic) |
| Unsubscribes from the specified topic in PROGMEM. | |
| bool | loop () |
| This should be called regularly to allow the client to process incoming messages and maintain its connection to the server. | |
| bool | connected () |
| Checks whether the client is connected to the server. | |
| int | state () |
| Returns the current state of the client. If a connection attempt fails, this can be used to get more information about the failure. | |
This class provides a client for doing simple publish and subscribe messaging with a server that supports MQTT.
Definition at line 180 of file PubSubClient.h.
| PubSubClient::PubSubClient | ( | ) |
Creates an uninitialised client instance.
Definition at line 43 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | Client & | client | ) |
Creates a partially initialised client instance.
| client | The network client to use, for example WiFiClient. |
Definition at line 49 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | IPAddress | addr, |
| uint16_t | port, | ||
| Client & | client ) |
Creates a fully configured client instance.
| addr | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
Definition at line 53 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | IPAddress | addr, |
| uint16_t | port, | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| addr | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 58 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | IPAddress | addr, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client ) |
Creates a fully configured client instance.
| addr | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
Definition at line 64 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | IPAddress | addr, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| addr | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 70 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | uint8_t * | ip, |
| uint16_t | port, | ||
| Client & | client ) |
Creates a fully configured client instance.
| ip | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
Definition at line 77 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | uint8_t * | ip, |
| uint16_t | port, | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| ip | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 82 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | uint8_t * | ip, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client ) |
Creates a fully configured client instance.
| ip | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
Definition at line 88 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | uint8_t * | ip, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| ip | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 94 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | const char * | domain, |
| uint16_t | port, | ||
| Client & | client ) |
Creates a fully configured client instance.
| domain | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
Definition at line 101 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | const char * | domain, |
| uint16_t | port, | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| domain | The address of the server. |
| port | The port to connect to. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 106 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | const char * | domain, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client ) |
Creates a fully configured client instance.
| domain | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
Definition at line 112 of file PubSubClient.cpp.
| PubSubClient::PubSubClient | ( | const char * | domain, |
| uint16_t | port, | ||
| MQTT_CALLBACK_SIGNATURE | , | ||
| Client & | client, | ||
| Stream & | stream ) |
Creates a fully configured client instance.
| domain | The address of the server. |
| port | The port to connect to. |
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
| client | The network client to use, for example WiFiClient. |
| stream | A stream to write received messages to. |
Definition at line 118 of file PubSubClient.cpp.
| PubSubClient::~PubSubClient | ( | ) |
Destructor for the PubSubClient class.
Definition at line 125 of file PubSubClient.cpp.
|
inline |
Start to publish a message using a topic from __FlashStringHelper F(). This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time.
| topic | The topic from __FlashStringHelper to publish to. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 759 of file PubSubClient.h.
|
inline |
Start to publish a message using QoS 0. This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time.
| topic | The topic to publish to. |
| plength | The length of the payload. |
| retained | Publish the message with the retain flag. |
Definition at line 721 of file PubSubClient.h.
|
inline |
Start to publish a message. This API: beginPublish(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time.
| topic | The topic to publish to. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 740 of file PubSubClient.h.
|
inline |
Start to publish a message using a topic in PROGMEM. This API: beginPublish_P(...) one or more calls to write(...) endPublish() Allows for arbitrarily large payloads to be sent without them having to be copied into a new buffer and held in memory at one time.
| topic | The topic in PROGMEM to publish to. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 779 of file PubSubClient.h.
|
inline |
Connects the client using a clean session without username and password.
| id | The client ID to use when connecting to the server. |
Definition at line 444 of file PubSubClient.h.
|
inline |
Connects the client using a clean session with username and password.
| id | The client ID to use when connecting to the server. |
| user | The username to use. |
| pass | The password to use. |
Definition at line 458 of file PubSubClient.h.
|
inline |
Connects the client using a clean session with username, password and will.
| id | The client ID to use when connecting to the server. |
| user | The username to use. |
| pass | The password to use. |
| willTopic | The topic to be used by the will message. |
| willQos | The quality of service to be used by the will message. [0, 1, 2]. |
| willRetain | Publish the will message with the retain flag. |
| willMessage | The message to be used by the will message. |
Definition at line 492 of file PubSubClient.h.
| bool PubSubClient::connect | ( | const char * | id, |
| const char * | user, | ||
| const char * | pass, | ||
| const char * | willTopic, | ||
| uint8_t | willQos, | ||
| bool | willRetain, | ||
| const char * | willMessage, | ||
| bool | cleanSession ) |
Connects the client with all possible parameters (user, password, will and session).
| id | The client ID to use when connecting to the server. |
| user | The username to use. |
| pass | The password to use. |
| willTopic | The topic to be used by the will message. |
| willQos | The quality of service to be used by the will message. [0, 1, 2]. |
| willRetain | Publish the will message with the retain flag. |
| willMessage | The message to be used by the will message. |
| cleanSession | True to connect with a clean session. |
Definition at line 130 of file PubSubClient.cpp.
|
inline |
Connects the client using a clean session and will.
| id | The client ID to use when connecting to the server. |
| willTopic | The topic to be used by the will message. |
| willQos | The quality of service to be used by the will message. [0, 1, 2]. |
| willRetain | Publish the will message with the retain flag. |
| willMessage | The message to be used by the will message. |
Definition at line 473 of file PubSubClient.h.
| bool PubSubClient::connected | ( | ) |
Checks whether the client is connected to the server.
Definition at line 235 of file PubSubClient.cpp.
| void PubSubClient::disconnect | ( | ) |
Disconnects the client.
Definition at line 250 of file PubSubClient.cpp.
| bool PubSubClient::endPublish | ( | ) |
Finish sending a message that was started with a call to beginPublish.
Definition at line 631 of file PubSubClient.cpp.
| size_t PubSubClient::getBufferSize | ( | ) |
Gets the current size of the internal buffer.
Definition at line 959 of file PubSubClient.cpp.
| bool PubSubClient::loop | ( | ) |
This should be called regularly to allow the client to process incoming messages and maintain its connection to the server.
Definition at line 508 of file PubSubClient.cpp.
|
inline |
Publishes a message from __FlashStringHelper to the specified topic from __FlashStringHelper.
| topic | The topic to publish to. |
| payload | The message to publish. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 579 of file PubSubClient.h.
|
inline |
Publishes a message to the specified topic.
| topic | The topic from __FlashStringHelper to publish to. |
| payload | The message to publish. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 566 of file PubSubClient.h.
| bool PubSubClient::publish | ( | const __FlashStringHelper * | topic, |
| const uint8_t * | payload, | ||
| size_t | plength, | ||
| uint8_t | qos, | ||
| bool | retained ) |
Publishes a message to the specified topic.
| topic | The topic from __FlashStringHelper to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 563 of file PubSubClient.cpp.
|
inline |
Publishes a non retained message to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
Definition at line 528 of file PubSubClient.h.
|
inline |
Publishes a message to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
| retained | Publish the message with the retain flag. |
Definition at line 540 of file PubSubClient.h.
|
inline |
Publishes a message to the specified topic.
| topic | The topic to publish to. |
| payload | The message to publish. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 553 of file PubSubClient.h.
|
inline |
Publishes a non retained message to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
Definition at line 591 of file PubSubClient.h.
|
inline |
Publishes a message to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
| retained | Publish the message with the retain flag. |
Definition at line 604 of file PubSubClient.h.
| bool PubSubClient::publish | ( | const char * | topic, |
| const uint8_t * | payload, | ||
| size_t | plength, | ||
| uint8_t | qos, | ||
| bool | retained ) |
Publishes a message to the specified topic.
| topic | The topic to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 555 of file PubSubClient.cpp.
| bool PubSubClient::publish_P | ( | const __FlashStringHelper * | topic, |
| const uint8_t * | payload, | ||
| size_t | plength, | ||
| uint8_t | qos, | ||
| bool | retained ) |
Publishes a message stored in PROGMEM to the specified topic.
| topic | The topic from __FlashStringHelper to publish to. |
| payload | The message from PROGMEM to publish. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 579 of file PubSubClient.cpp.
|
inline |
Publishes a message stored in PROGMEM to the specified topic.
| topic | The topic from __FlashStringHelper to publish to. |
| payload | The message to publish. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 666 of file PubSubClient.h.
|
inline |
Publishes a message stored in PROGMEM to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
| retained | Publish the message with the retain flag. |
Definition at line 679 of file PubSubClient.h.
| bool PubSubClient::publish_P | ( | const char * | topic, |
| const uint8_t * | payload, | ||
| size_t | plength, | ||
| uint8_t | qos, | ||
| bool | retained ) |
Publishes a message stored in PROGMEM to the specified topic.
| topic | The topic to publish to. |
| payload | The message to publish. |
| plength | The length of the payload. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 571 of file PubSubClient.cpp.
|
inline |
Publishes a message stored in PROGMEM to the specified topic using QoS 0.
| topic | The topic to publish to. |
| payload | The message to publish. |
| retained | Publish the message with the retain flag. |
Definition at line 640 of file PubSubClient.h.
|
inline |
Publishes a message stored in PROGMEM to the specified topic.
| topic | The topic to publish to. |
| payload | The message to publish. |
| qos | The quality of service (QoS levels) to publish at. [0, 1, 2]. |
| retained | Publish the message with the retain flag. |
Definition at line 653 of file PubSubClient.h.
| bool PubSubClient::setBufferSize | ( | size_t | size | ) |
Sets the size, in bytes, of the internal send and receive buffer. This must be large enough to contain the full MQTT packet. When sending or receiving messages, the packet will contain the full topic string, the payload data, and a small number of header bytes.
| size | The size, in bytes, for the internal buffer. |
Definition at line 937 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setCallback | ( | MQTT_CALLBACK_SIGNATURE | ) |
Sets the message callback function.
| callback | Pointer to a message callback function. Called when a message arrives for a subscription created by this client. |
Definition at line 922 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setClient | ( | Client & | client | ) |
Sets the network client instance to use.
| client | The network client to use, for example WiFiClient. |
Definition at line 927 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setKeepAlive | ( | uint16_t | keepAlive | ) |
Sets the keep alive interval used by the client. This value should only be changed when the client is not connected. Set keepAlive to zero (0) to turn off the keep alive mechanism.
| keepAlive | The keep alive interval, in seconds. |
Definition at line 963 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setServer | ( | const char * | domain, |
| uint16_t | port ) |
Sets the server details.
| domain | The address of the server. |
| port | The port to connect to. |
Definition at line 905 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setServer | ( | IPAddress | ip, |
| uint16_t | port ) |
Sets the server details.
| ip | The address of the server. |
| port | The port to connect to. |
Definition at line 897 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setServer | ( | uint8_t * | ip, |
| uint16_t | port ) |
Sets the server details.
| ip | The address of the server. |
| port | The port to connect to. |
Definition at line 892 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setSocketTimeout | ( | uint16_t | timeout | ) |
Sets the socket timeout used by the client. This determines how long the client will wait for incoming data when it expects data to arrive - for example, whilst it is in the middle of reading a MQTT packet.
| timeout | The socket timeout, in seconds. |
Definition at line 968 of file PubSubClient.cpp.
| PubSubClient & PubSubClient::setStream | ( | Stream & | stream | ) |
Sets the stream to write received messages to.
| stream | A stream to write received messages to. |
Definition at line 932 of file PubSubClient.cpp.
| int PubSubClient::state | ( | ) |
Returns the current state of the client. If a connection attempt fails, this can be used to get more information about the failure.
Definition at line 973 of file PubSubClient.cpp.
|
inline |
Subscribes to messages published to the specified topic from __FlashStringHelper using QoS 0.
| topic | The topic from __FlashStringHelper to subscribe to. |
Definition at line 846 of file PubSubClient.h.
|
inline |
Subscribes to messages published to the specified topic from __FlashStringHelper.
| topic | The topic from __FlashStringHelper to subscribe to. |
| qos | The qos to subscribe at. [0, 1]. |
Definition at line 879 of file PubSubClient.h.
|
inline |
Subscribes to messages published to the specified topic using QoS 0.
| topic | The topic to subscribe to. |
Definition at line 836 of file PubSubClient.h.
|
inline |
Subscribes to messages published to the specified topic.
| topic | The topic to subscribe to. |
| qos | The qos to subscribe at. [0, 1]. |
Definition at line 868 of file PubSubClient.h.
|
inline |
Subscribes to messages published to the specified topic in PROGMEM using QoS 0.
| topic | The topic in PROGMEM to subscribe to. |
Definition at line 857 of file PubSubClient.h.
|
inline |
Subscribes to messages published to the specified topic in PROGMEM.
| topic | The topic in PROGMEM to subscribe to. |
| qos | The qos to subscribe at. [0, 1]. |
Definition at line 891 of file PubSubClient.h.
|
inline |
Unsubscribes from the specified topic from __FlashStringHelper.
| topic | The topic from __FlashStringHelper to unsubscribe from. |
Definition at line 911 of file PubSubClient.h.
|
inline |
Unsubscribes from the specified topic.
| topic | The topic to unsubscribe from. |
Definition at line 901 of file PubSubClient.h.
|
inline |
Unsubscribes from the specified topic in PROGMEM.
| topic | The topic in PROGMEM to unsubscribe from. |
Definition at line 922 of file PubSubClient.h.
|
virtual |
Writes an array of bytes as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish().
| buf | The bytes to write. |
| size | The length of the payload to be sent. |
Definition at line 679 of file PubSubClient.cpp.
|
virtual |
Writes a single byte as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish().
| data | A byte to write to the publish payload. |
Definition at line 675 of file PubSubClient.cpp.
| size_t PubSubClient::write_P | ( | const uint8_t * | buf, |
| size_t | size ) |
Writes an array of progmem bytes as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish().
| buf | The bytes to write. |
| size | The length of the payload to be sent. |
Definition at line 686 of file PubSubClient.cpp.
|
inline |
Writes a string in PROGMEM as a component of a publish started with a call to beginPublish. For performance reasons, this will be appended to the internal buffer, which will be flushed when full or on a call to endPublish().
| string | The message to write. |
Definition at line 816 of file PubSubClient.h.