Mqtt Client

Table of Contents

Example Summary

This example introduce the MQTT Client library API and usage.

Peripherals Exercised

LED indication Led Color Interpretation
Solidly on Green Indicate Simplelink is properly up - Every Reset / Initialize
Blinking Red Device is trying to connect to AP - Every Reset / Initialize
Solidly off All Device connected and working - Only after connection
Toggling (Solidly on/off) Red Publish message received in SUBSCRIPTION_TOPIC1
Toggling (Solidly on/off) Yellow Publish message received in SUBSCRIPTION_TOPIC2
Toggling (Solidly on/off) Green Publish message received in SUBSCRIPTION_TOPIC3

Example Usage

The application have one MQTT entity
MQTT Client Role - Can connect to remote broker

Application Design Details

MQTT Client application used to demonstrate the client side of the MQTT protocol. It does that by offering a semi-automatic application.

The application starts with invoking the ‘Mqtt_IF_Connect()’ command which tries to connect to a specific AP which his SSID is hard coded in Network_if.h file, in case the connection to the AP fails, the user will be requested to fill the SSID of an open AP to connect to.

After connection success, the application invokes the ‘MqttClient_start’ command which set all the parameter that are required to create TCP/TLS/SSL connection to the broker, invokes the ‘MQTTClient_connect(gMqttClient)’ command which create the connection to the broker and then invokes the ‘MQTTClient_subscribe(gMqttClient , subscriptionInfo, SUBSCRIPTION_TOPIC_COUNT)’ command which subscribe the client topics which are hard coded in ‘Mqtt_client_app.c’

Now the client can receive publish messages from the borker. In this example the topics in the left will toggle the LEDs in the right

                        "/cc3200/ToggleLEDCmdL1" <-------------> toggle LED0  
                        "/cc3200/ToggleLEDCmdL2" <-------------> toggle LED1  
                        "/cc3200/ToggleLEDCmdL3" <-------------> toggle LED2   

The user can invoke more commands by pressing the push buttons on the CC32XX launchpad device:


MQTT Org - MQTT Home page
MQTT v3.1.1 specification
MQTT v3.1 specification