About MQTT-client
Goals
µC/MQTT-client product can be used to access public MQTT servers and perform actions on resources maintained by a server.
In an embedded environment, an MQTT client will primarily be used to publish small messages to a server and subscribe to some topics of interest so that it may receive messages from other MQTT clients, via the server.
Design
µC/MQTT-client has been designed to use a very small footprint and to be as simple to use as possible. It also supports opening multiple connection to multiple servers, allowing to send or receive message to/from different sources. It also uses a similar API to other Micrium products, allowing users to start developing faster if they have used one of the other Micrium products.
Memory Usage
Each MQTT client application can have very different memory needs. For example, some applications will only require connection to one server whereas others will require more; some applications will prefer to allocate objects on their own Stack while others will want to use a memory pool on the Heap. Therefore, to conform with all of these different requirements, µC/MQTT-client does not have its own memory module. All the objects required by the µC/MQTT-client MUST be passed by the application. A single MQTT Client Message must be provided by the Application, it will be use to receive any PUBLISH message from the server and to reply to it, if needed. For any message the Application wishes to send to the server, a message must also be provided. Each message must have their own buffer, with a size varying from a few bytes for very simple messages to possibly a couple of hundreds for very complex messages.
It is very important that every objects passed by the application to µC/MQTT-client stay valid for the duration of the MQTT message (until the callback is called) or until the connection is closed for the MQTTc Connection Object.
Internal Task
To support multiple simultaneous connections, µC/MQTT-client has an internal task. This task also allows the queuing of multiple messages on a given connection. This task is mandatory, the Application must provide the µC/MQTT-client module with the priority of the internal task, the stack for the task to use and an optional delay for the task.
Auto Select Remote IP address
When µC/DNSc is present, µC/MQTT-client can accept a host name string to connect to the remote server. It will perform the IP address resolution by communicating with a DNS server. If the DNS server sends back IPv4 and IPv6 addresses, the first attempt will be to use the IPv6 address to connect to the remote MQTT server. If this connection fails the IPv4 address will be used instead.
When µC/DNSc is not present, an IPv4 or IPv6 remote address in string form must be passed to µC/MQTT-client to connect to the remote server.
With its compile-time configuration, µC/HTTP-client's code footprint can be adjusted to fit the Application requirements by enabling/disabling features.
Features
µC/MQTT-client supports:
- Multiple connections to multiple servers
- Every type of messages defined by the MQTT specifications V3.1 and V3.1.1, including the three levels of QoS for
PUBLISH
messages
See the section MQTT-client Message Types Supported for additional details on each feature available.