Serval_Mqtt.h File Reference

Implementation of the MQTT protocol. More...

#include <Serval_Defines.h>
+ Include dependency graph for Serval_Mqtt.h:
+ This graph shows which files directly or indirectly include this file:



Detailed Description


WARNING: This implementation is experimental in order to obtain feedback about the API. It is still subject to change.

The MQTT API is designed around the idea of one or more MQTT sessions. The application defines a MqttSession_T structure and fills it with all necessary information to connect to a MQTT server.

The interaction with the session occurs via the remaining Mqtt_* functions, incoming data and confirmation of other events, e.g. subscription or connection, are communicated to the application via the onMqttEvent callback in the session.

Each event will carry with it event-specific data which allow the application to understand the context of the event.

The API is straightforward:

MqttSession_T session;
retcode_t onMqttEvent(MqttSession_T* session, MqttEvent_t eventType, const MqttEventData_t* eventData)
//handle incoming events, session established, incoming published, etc. here.
return RC_OK;
void mqttExample(void)
retcode_t rc = Mqtt_initialize();
if ( rc != RC_OK )
LOG_ERROR("Could not initialize mqtt, error 0x%04x\n", rc);
memset(&session, 0, sizeof(session));
session.onMqttEvent = onMqttEvent;
//fill remaining session structure, e.g. using
//SupportedUrl_fromString(destination, strlen(destination), &;
rc = Mqtt_connect(&session);
if ( rc != RC_OK )
LOG_ERROR("Could not connect, error 0x%04x\n", rc);
// call Mqtt_subscribe and Mqtt_publish as required

Macro Definition Documentation


Max number of MQTT connections that can be handled

This documentation file has been automatically generated on Wed May 6 2020 20:45:13 by doxygen 1.8.8