Configuring the MQTT library for testing - FreeRTOS

Configuring the MQTT library for testing

Devices on the edge can use the MQTT protocol to communicate with the AWS Cloud. AWS IoT hosts an MQTT broker that sends and receives messages to and from connected devices at the edge.

The MQTT library implements the MQTT protocol for devices running FreeRTOS. The MQTT library does not need to be ported, but your device's test project must pass all MQTT tests for qualification. For more information, see FreeRTOS MQTT Library in the FreeRTOS User Guide.


To set up the FreeRTOS MQTT library tests, you need the following:

  • A port of the TLS library.

    For information about porting the TLS library to your platform, see Porting the TLS library.

If you are using an IDE to build test projects, you need to set up your library port in the IDE project.

Setting up the IDE test project

To set up the MQTT library in the IDE project

  • Add all of the test source files in freertos/libraries/c_sdk/standard/mqtt and its subdirectories to the aws_tests IDE project.

Configuring the CMakeLists.txt file

If you are using CMake to build your test project, you need to define a portable layer target for the library in your CMake list file.

To define a library's portable layer target in CMakeLists.txt, follow the instructions in FreeRTOS portable layers.

The CMakeLists.txt template list file under freertos/vendors/vendor/boards/board/CMakeLists.txt includes example portable layer target definitions. You can uncomment the definition for the library that you are porting, and modify it to fit your platform.

Setting up your local testing environment

After you set up the library in the IDE project, you need to configure some other files for testing.

To configure the source and header files for the MQTT tests

  • To enable the MQTT tests, open freertos/vendors/vendor/boards/board/aws_tests/config_files/aws_test_runner_config.h, and set the testrunnerFULL_MQTTv4_ENABLED macro to 1.

Running the tests

To execute the MQTT tests

  1. Build the test project, and then flash it to your device for execution.

  2. Check the test results in the UART console. If all tests pass, then testing is complete.


To officially qualify a device for FreeRTOS, you need to validate the device's ported source code with AWS IoT Device Tester. Follow the instructions in Using AWS IoT Device Tester for FreeRTOS in the FreeRTOS User Guide to set up Device Tester for port validation. To test a specific library's port, the correct test group must be enabled in the device.json file in the Device Tester configs folder.

After you finish setting up the FreeRTOS MQTT library for your device, you can start porting the OTA agent library. See Porting the OTA library for instructions.

If your device does not support OTA functionality, you can start porting the Bluetooth Low Energy library. See Porting the Bluetooth Low Energy library for instructions.

If your device does not support OTA and Bluetooth Low Energy functionality, then you are finished porting and can start the FreeRTOS qualification process. See the FreeRTOS Qualification Guide for more information.