Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mqtt_client.c File Reference
MQTT client. More...
Go to the source code of this file.
Functions | |
| void | mqttClientInit (MqttClientContext *context) |
| Initialize MQTT client context. | |
| void | mqttClientInitCallbacks (MqttClientCallbacks *callbacks) |
| Initialize callback structure. | |
| error_t | mqttClientRegisterCallbacks (MqttClientContext *context, const MqttClientCallbacks *callbacks) |
| Register MQTT client callbacks. | |
| error_t | mqttClientSetProtocolLevel (MqttClientContext *context, MqttProtocolLevel protocolLevel) |
| Set the MQTT protocol version to be used. | |
| error_t | mqttClientSetTransportProtocol (MqttClientContext *context, MqttTransportProtocol transportProtocol) |
| Set the transport protocol to be used. | |
| error_t | mqttClientSetKeepAlive (MqttClientContext *context, uint16_t keepAlive) |
| Set keep-alive value. | |
| error_t | mqttClientSetTimeout (MqttClientContext *context, uint16_t timeout) |
| Set communication timeout. | |
| error_t | mqttClientSetHost (MqttClientContext *context, const char_t *host) |
| Set the hostname of the resource being requested. | |
| error_t | mqttClientSetUri (MqttClientContext *context, const char_t *uri) |
| Set the name of the resource being requested. | |
| error_t | mqttClientSetIdentifier (MqttClientContext *context, const char_t *clientId) |
| Set client identifier. | |
| error_t | mqttClientSetAuthInfo (MqttClientContext *context, const char_t *username, const char_t *password) |
| Set authentication information. | |
| error_t | mqttClientSetWillMessage (MqttClientContext *context, const char_t *topic, const void *message, size_t length, MqttQosLevel qos, bool_t retain) |
| Specify the Will message. | |
| error_t | mqttClientBindToInterface (MqttClientContext *context, NetInterface *interface) |
| Bind the MQTT client to a particular network interface. | |
| error_t | mqttClientConnect (MqttClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort, bool_t cleanSession) |
| Establish connection with the MQTT server. | |
| error_t | mqttClientPublish (MqttClientContext *context, const char_t *topic, const void *message, size_t length, MqttQosLevel qos, bool_t retain, uint16_t *packetId) |
| Publish message. | |
| error_t | mqttClientSubscribe (MqttClientContext *context, const char_t *topic, MqttQosLevel qos, uint16_t *packetId) |
| Subscribe to topics. | |
| error_t | mqttClientUnsubscribe (MqttClientContext *context, const char_t *topic, uint16_t *packetId) |
| Unsubscribe from topics. | |
| error_t | mqttClientPing (MqttClientContext *context, systime_t *rtt) |
| Send ping request. | |
| error_t | mqttClientDisconnect (MqttClientContext *context) |
| Gracefully disconnect from the MQTT server. | |
| error_t | mqttClientClose (MqttClientContext *context) |
| Close the connection with the MQTT server. | |
| error_t | mqttClientProcessEvents (MqttClientContext *context, systime_t timeout) |
| Process MQTT client events. | |
Detailed Description
MQTT client.
License
Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version:
- 1.7.6
Definition in file mqtt_client.c.
Function Documentation
| error_t mqttClientBindToInterface | ( | MqttClientContext * | context, |
| NetInterface * | interface | ||
| ) |
Bind the MQTT client to a particular network interface.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] interface Network interface to be used
- Returns:
- Error code
Definition at line 381 of file mqtt_client.c.
| error_t mqttClientClose | ( | MqttClientContext * | context ) |
Close the connection with the MQTT server.
- Parameters:
-
[in] context Pointer to the MQTT client context
- Returns:
- Error code
Definition at line 1044 of file mqtt_client.c.
| error_t mqttClientConnect | ( | MqttClientContext * | context, |
| const IpAddr * | serverIpAddr, | ||
| uint16_t | serverPort, | ||
| bool_t | cleanSession | ||
| ) |
Establish connection with the MQTT server.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] serverIpAddr IP address of the MQTT server to connect to [in] serverPort TCP port number that will be used to establish the connection [in] cleanSession If this flag is set, then the client and server must discard any previous session and start a new one
- Returns:
- Error code
Definition at line 407 of file mqtt_client.c.
| error_t mqttClientDisconnect | ( | MqttClientContext * | context ) |
Gracefully disconnect from the MQTT server.
- Parameters:
-
[in] context Pointer to the MQTT client context
- Returns:
- Error code
Definition at line 960 of file mqtt_client.c.
| void mqttClientInit | ( | MqttClientContext * | context ) |
Initialize MQTT client context.
- Parameters:
-
[in] context Pointer to the MQTT client context
Definition at line 49 of file mqtt_client.c.
| void mqttClientInitCallbacks | ( | MqttClientCallbacks * | callbacks ) |
Initialize callback structure.
- Parameters:
-
[in] callbacks Pointer to a structure that contains callback functions
- Returns:
- Error code
Definition at line 85 of file mqtt_client.c.
| error_t mqttClientPing | ( | MqttClientContext * | context, |
| systime_t * | rtt | ||
| ) |
Send ping request.
- Parameters:
-
[in] context Pointer to the MQTT client context [out] rtt Round-trip time (optional parameter)
- Returns:
- Error code
Definition at line 856 of file mqtt_client.c.
| error_t mqttClientProcessEvents | ( | MqttClientContext * | context, |
| systime_t | timeout | ||
| ) |
Process MQTT client events.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] timeout Maximum time to wait before returning
- Returns:
- Error code
Definition at line 1067 of file mqtt_client.c.
| error_t mqttClientPublish | ( | MqttClientContext * | context, |
| const char_t * | topic, | ||
| const void * | message, | ||
| size_t | length, | ||
| MqttQosLevel | qos, | ||
| bool_t | retain, | ||
| uint16_t * | packetId | ||
| ) |
Publish message.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] topic Topic name [in] message Message payload [in] length Length of the message payload [in] qos QoS level to be used when publishing the message [in] retain This flag specifies if the message is to be retained [out] packetId Packet identifier used to send the PUBLISH packet
- Returns:
- Error code
Definition at line 543 of file mqtt_client.c.
| error_t mqttClientRegisterCallbacks | ( | MqttClientContext * | context, |
| const MqttClientCallbacks * | callbacks | ||
| ) |
Register MQTT client callbacks.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] callbacks Pointer to a structure that contains callback functions
- Returns:
- Error code
Definition at line 99 of file mqtt_client.c.
| error_t mqttClientSetAuthInfo | ( | MqttClientContext * | context, |
| const char_t * | username, | ||
| const char_t * | password | ||
| ) |
Set authentication information.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] username NULL-terminated string containing the user name to be used [in] password NULL-terminated string containing the password to be used
- Returns:
- Error code
Definition at line 291 of file mqtt_client.c.
| error_t mqttClientSetHost | ( | MqttClientContext * | context, |
| const char_t * | host | ||
| ) |
Set the hostname of the resource being requested.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] host NULL-terminated string containing the hostname
- Returns:
- Error code
Definition at line 210 of file mqtt_client.c.
| error_t mqttClientSetIdentifier | ( | MqttClientContext * | context, |
| const char_t * | clientId | ||
| ) |
Set client identifier.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] clientId NULL-terminated string containing the client identifier
- Returns:
- Error code
Definition at line 264 of file mqtt_client.c.
| error_t mqttClientSetKeepAlive | ( | MqttClientContext * | context, |
| uint16_t | keepAlive | ||
| ) |
Set keep-alive value.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] keepAlive Maximum time interval that is permitted to elapse between the point at which the client finishes transmitting one control packet and the point it starts sending the next
- Returns:
- Error code
Definition at line 168 of file mqtt_client.c.
| error_t mqttClientSetProtocolLevel | ( | MqttClientContext * | context, |
| MqttProtocolLevel | protocolLevel | ||
| ) |
Set the MQTT protocol version to be used.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] protocolLevel MQTT protocol level (3.1 or 3.1.1)
- Returns:
- Error code
Definition at line 121 of file mqtt_client.c.
| error_t mqttClientSetTimeout | ( | MqttClientContext * | context, |
| uint16_t | timeout | ||
| ) |
Set communication timeout.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] timeout Timeout value, in seconds
- Returns:
- Error code
Definition at line 189 of file mqtt_client.c.
| error_t mqttClientSetTransportProtocol | ( | MqttClientContext * | context, |
| MqttTransportProtocol | transportProtocol | ||
| ) |
Set the transport protocol to be used.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] transportProtocol Transport protocol to be used (TCP, TLS, WebSocket, or secure WebSocket)
- Returns:
- Error code
Definition at line 144 of file mqtt_client.c.
| error_t mqttClientSetUri | ( | MqttClientContext * | context, |
| const char_t * | uri | ||
| ) |
Set the name of the resource being requested.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] uri NULL-terminated string containing the URI
- Returns:
- Error code
Definition at line 237 of file mqtt_client.c.
| error_t mqttClientSetWillMessage | ( | MqttClientContext * | context, |
| const char_t * | topic, | ||
| const void * | message, | ||
| size_t | length, | ||
| MqttQosLevel | qos, | ||
| bool_t | retain | ||
| ) |
Specify the Will message.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] topic Will topic name [in] message Will message [in] length Length of the Will message [in] qos QoS level to be used when publishing the Will message [in] retain This flag specifies if the Will message is to be retained
- Returns:
- Error code
Definition at line 328 of file mqtt_client.c.
| error_t mqttClientSubscribe | ( | MqttClientContext * | context, |
| const char_t * | topic, | ||
| MqttQosLevel | qos, | ||
| uint16_t * | packetId | ||
| ) |
Subscribe to topics.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] topic Topic filter [in] qos Maximum QoS level at which the server can send application messages to the client [out] packetId Packet identifier used to send the SUBSCRIBE packet
- Returns:
- Error code
Definition at line 657 of file mqtt_client.c.
| error_t mqttClientUnsubscribe | ( | MqttClientContext * | context, |
| const char_t * | topic, | ||
| uint16_t * | packetId | ||
| ) |
Unsubscribe from topics.
- Parameters:
-
[in] context Pointer to the MQTT client context [in] topic Topic filter [out] packetId Packet identifier used to send the UNSUBSCRIBE packet
- Returns:
- Error code
Definition at line 757 of file mqtt_client.c.
Generated on Tue Jul 12 2022 17:10:21 by
1.7.2