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
Last updated
Was this helpful?