1#ifndef Arduino_MQTT_Client_h
2#define Arduino_MQTT_Client_h
10#include <PubSubClient.h>
24 Arduino_MQTT_Client() =
default;
29 Arduino_MQTT_Client(Client & transport_client);
31 ~Arduino_MQTT_Client()
override =
default;
36 void set_client(Client & transport_client);
42 bool set_buffer_size(uint16_t receive_buffer_size, uint16_t send_buffer_size)
override;
48 void set_server(
char const * domain, uint16_t port)
override;
50 bool connect(
char const * client_id,
char const * user_name,
char const * password)
override;
56 bool publish(
char const * topic,
uint8_t const * payload,
size_t const & length)
override;
58 bool subscribe(
char const * topic)
override;
70#if THINGSBOARD_ENABLE_STREAM_UTILS
72 bool begin_publish(
char const * topic,
size_t const & length)
override;
74 bool end_publish()
override;
80 size_t write(
uint8_t payload_byte)
override;
82 size_t write(
uint8_t const * buffer,
size_t const & size)
override;
87 MQTT_Connection_Error connect_mqtt_client(
char const * client_id,
char const * user_name,
char const * password);
97 PubSubClient m_mqtt_client = {};
MQTT_Connection_Error
Possible error states the MQTT broker connection can be in, if connecting the device to the MQTT brok...
Definition: MQTT_Connection_Error.h:9
MQTT_Connection_State
Possible states the MQTT broker connection can be in.
Definition: MQTT_Connection_State.h:11
General purpose safe callback wrapper. Expects either c-style or c++ style function pointer,...
Definition: Callback.h:30
std::function< return_type(argument_types... arguments)> function
Callback signature.
Definition: Callback.h:34
MQTT Client interface that contains the method that a class that can be used to send and receive data...
Definition: IMQTT_Client.h:36
virtual void disconnect()=0
Force disconnects from the previously connected server and should release all used resources.
virtual bool loop()=0
Receives / sends any outstanding messages from and to the MQTT broker.
virtual bool connect(char const *client_id, char const *user_name, char const *password)=0
Connects to the previously with set_server configured server instance and port with the given credent...
virtual void subscribe_connection_state_changed_callback(Callback< void, MQTT_Connection_State, MQTT_Connection_Error >::function callback)=0
Sets the callback that is called, whenever the underlying state of our connection with the MQTT broke...
virtual MQTT_Connection_Error get_last_connection_error() const =0
Allows to deciper the reason for a failure, while attempting to establish a connection to the MQTT br...
virtual uint16_t get_receive_buffer_size()=0
Gets the previously set size of the internal buffer size meant for incoming MQTT data.
virtual void set_data_callback(Callback< void, char *, uint8_t *, unsigned int >::function callback)=0
Sets the callback that is called, if any message is received by the MQTT broker.
virtual bool unsubscribe(char const *topic)=0
Unsubscribes to previously subscribed MQTT messages of the given topic.
virtual bool set_buffer_size(uint16_t receive_buffer_size, uint16_t send_buffer_size)=0
Changes the size of the buffer for sent and received MQTT messages.
virtual MQTT_Connection_State get_connection_state() const =0
Get the current connection state to the server includes possible intermediate states between connecti...
virtual void set_server(char const *domain, uint16_t port)=0
Configures the server and port that the client should connect with over MQTT.
virtual bool publish(char const *topic, uint8_t const *payload, size_t const &length)=0
Sends the given payload over the previously established connection.
virtual uint16_t get_send_buffer_size()=0
Gets the previously set size of the internal buffer size meant for outgoing MQTT data.
virtual bool connected()=0
Returns our current connection status to MQTT, true meaning we are connected, false meaning we have b...
virtual bool subscribe(char const *topic)=0
Subscribes to MQTT message on the given topic, which will cause an internal callback to be called for...
virtual void set_connect_callback(Callback< void >::function callback)=0
Sets the callback that is called, if we have successfully established a connection with the MQTT brok...