MqttClient.h
Go to the documentation of this file.
233 static int staticOnDataPayload(void* user_data, mqtt_message_t* message, const char* data, size_t length);
273 String topic = String((const char*)message->publish.topic_name.data, message->publish.topic_name.length);
Definition: MqttClient.h:30
void setSslInitHandler(Ssl::Session::InitDelegate handler)
Set the SSL session initialisation callback.
Definition: TcpConnection.h:112
void setCompleteDelegate(TcpClientCompleteDelegate completeCb=nullptr)
Set or clear the callback for connection close.
Definition: TcpClient.h:98
void onFinished(TcpClientState finishState) override
void setPayloadParser(MqttPayloadParser payloadParser=nullptr)
Sets or clears a payload parser (for PUBLISH messages from the server to us)
Definition: MqttClient.h:112
void setDisconnectHandler(TcpClientCompleteDelegate handler)
Sets a handler to be called on disconnect from the server.
Definition: MqttClient.h:156
Definition: MqttClient.h:57
Ssl::Session * getSsl()
Get a pointer to the current SSL session object.
Definition: TcpConnection.h:135
bool connect(const Url &url, const String &uniqueClientName)
Connect to a MQTT server.
Definition: MqttClient.h:30
void setPingRepeatTime(unsigned seconds)
bool setWill(const String &topic, const String &message, uint8_t flags=0)
void setMessageHandler(MqttDelegate handler)
Sets a handler to be called after receiving a PUBLISH message from the server.
Definition: MqttClient.h:146
MqttClient(bool withDefaultPayloadParser=true, bool autoDestruct=false)
bool setWill(const String &topic, const String &message, int QoS, bool retained=false)
Definition: MqttClient.h:176
Definition: TcpClient.h:46
Definition: Delegate.h:20
Definition: MqttPayloadParser.h:29
bool publish(const String &topic, const String &message, uint8_t flags=0)
bool subscribe(const String &topic)
void setCallback(MqttStringSubscriptionCallback subscriptionCallback=nullptr)
Provide a function to be called when a message is received from the broker.
Definition: MqttClient.h:215
bool publishWithQoS(const String &topic, const String &message, int QoS, bool retained=false, MqttMessageDeliveredCallback onDelivery=nullptr)
Definition: MqttClient.h:193
ObjectQueue< mqtt_message_t, MQTT_REQUEST_POOL_SIZE > MqttRequestQueue
Definition: MqttClient.h:48
void setConnectedHandler(MqttDelegate handler)
Sets a handler to be called after successful MQTT connection.
Definition: MqttClient.h:124
Delegate< void(uint16_t msgId, int type)> MqttMessageDeliveredCallback
Definition: MqttClient.h:54
void onReadyToSendData(TcpConnectionEvent sourceEvent) override
void setPublishedHandler(MqttDelegate handler)
Sets a handler to be called after receiving confirmation from the server for a published message from...
Definition: MqttClient.h:135
Delegate< int(MqttClient &client, mqtt_message_t *message)> MqttDelegate
Definition: MqttClient.h:45
Delegate< void(String topic, String message)> MqttStringSubscriptionCallback
Definition: MqttClient.h:52
IDataSourceStream * stream
The currently active stream being sent.
Definition: TcpClient.h:145
void setKeepAlive(uint16_t seconds)
Sets keep-alive time. That information is sent during connection to the server.
Definition: MqttClient.h:68
~MqttClient()
void setEventHandler(mqtt_type_t type, MqttDelegate handler)
Definition: MqttClient.h:101
bool unsubscribe(const String &topic)