MQTT Client

Example Summary

This example introduces the MQTT Client API and usage for the CC35xx family of devices.

Peripherals Exercised

The following table lists all LED options.

LED indication Led Color for CC35xx Interpretation
Solidly on Green Indicates CC35xx is connected to the local AP
Solidly on Red Indicates CC35xx is connected to the MQTT Broker
Toggling on/off Red Publish message received in cc35xx/ToggleLED topic with the word *red* in the message payload
Toggling on/off Green Publish message received in cc35xx/ToggleLED topic with the word *green* in the message payload
Toggling on/off Blue Publish message received in cc35xx/ToggleLED topic with the word *blue* in the message payload

Example Usage

Application Design Details

This is an MQTT Client application used to demonstrate the client side of the MQTT protocol. This application uses an MQTT module (mqtt_if.c) as an abstraction layer to the LwIP’s internal MQTT library to make it easier for developers to use MQTT.

The application flow includes:

  1. The application starts by performing all the necessary initializations for the peripherals (e.g. GPIO, I2C, UART and timer).
  2. Once that is done, the application calls WIFI_IF_init() that is responsible to start the Wi-Fi and load the containers (RAM bootloader, firmware and configuration binary), and also initialize the TCPIP network stack.
  3. Then, MQTT is initialized via the MQTT_IF_init().
  4. The application attempts to connect to an AP via the WIFI_IF_start(), using the credentials the user configured in wifi_settings.h.
  5. Upon successful Wi-Fi connection, the application attempts to connect to an MQTT broker via the MQTT_IF_clientConnect().
  6. Upon successful MQTT connection, the various topics can be controlled over the MQTT cloud with a second MQTT peer device (e.g. the mobile phone).

The following messages should appear on the terminal when invoking the different topics:

Limitations

References

MQTT Org - MQTT Home page
MQTT specifications