XDK API  3.6.0
Documentation
Macros
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:

Macros

#define SERVAL_MQTT_MAX_NUM_SESSIONS   1
 

Detailed Description

Since
1.9

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));
Mqtt_initializeInternalSession(&session);
session.onMqttEvent = onMqttEvent;
//fill remaining session structure, e.g. using
//SupportedUrl_fromString(destination, strlen(destination), &session.target);
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

#define SERVAL_MQTT_MAX_NUM_SESSIONS   1

Max number of MQTT connections that can be handled


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:46 by doxygen 1.8.8