# Overview

To make the API available to the application, the header file Serval\_Mqtt.h has to be included in the implementation files.

The following table lists some of the important functions of the MQTT API.

| Function                          | Description                                                                                                                                                                                                              |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Mqtt\_initialize()                | This function is used to initialize the MQTT module and should be used before any other function of the MQTT API                                                                                                         |
| Mqtt\_initializeInternalSession() | This function is used to initialize the internal session. The session will hold all the information needed to connect to an MQTT broker                                                                                  |
| (\*MqttEventCallback\_T)()        | This is a function that has to be implemented by the user of the API. On every MQTT Event, this function is called and will be used for handling the events. For more details, see chapter Event Handler of this section |
| Mqtt\_connect()                   | This function attempts to connect to the target host. The target host is a field of the MqttSession\_T and should be configured before this function is called.                                                          |
| Mqtt\_publish()                   | This function publishes data. The inputs are:Topic (of type `StringDescr_T`)Payload ( + Length)Quality of ServiceRetain Flag                                                                                             |
| Mqtt\_subscribe()                 | This function subscribe to a list of topics with their respective QoS. The inputs are:List of Topics (of type `StringDescr_T`)List of QoS (of type `Mqtt_qos_t`)                                                         |

All these functions, except `Mqtt_initialize()`, receive the pointer to a `MqttSess`
