Download FreeRTOS

Quality RTOS & Embedded Software

Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.
The menu on the left links to demo projects suitable for learning to use the MQTT Agent library. Separately, the IoT Reference Integrations section demonstrates the library integrated into an application.

coreMQTT Agent
Thread-safe MQTT C client library for small IoT devices (MCU or small MPU)


The coreMQTT Agent library is a high level API that adds thread safety to the coreMQTT library. It lets you create a dedicated MQTT agent task that manages an MQTT connection in the background and doesn't need any intervention from other tasks. The library provides thread safe equivalents to the coreMQTT's APIs, so it can be used in multi-threaded environments.

The MQTT agent is an independent task (or thread of execution). It achieves thread safety by being the only task that is permitted to access the MQTT library's API. It serializes access by isolating all MQTT API calls to a single task, and it removes the need for semaphores or any other synchronization primitives.

The library uses a thread safe messaging queue (or other inter-process communication mechanism) to serialize all requests to call MQTT APIs. The messaging implementation is decoupled from the library through a messaging interface, which allows the library to be ported to other operating systems. The messaging interface is composed of functions to send and receive pointers to the agent's command structures, and functions to allocate these command objects, which allows the application writer to decide the memory allocation strategy appropriate for their application.

The library is written in C and designed to be compliant with ISO C90 and MISRA C:2012. The library has no dependencies on any additional libraries other than coreMQTT and the standard C library. The library has proofs that show safe memory use and no heap allocation, so it can be used for IoT microcontrollers, but is also fully portable to other platforms.

This library can be freely used and is distributed under the MIT open source license.


Code Size of coreMQTT Agent (example generated with GCC for ARM Cortex-M)
FileWith -O1 OptimizationWith -Os Optimization
core_mqtt.c (coreMQTT)4.0K3.4K
core_mqtt_state.c (coreMQTT)1.7K1.3K
core_mqtt_serializer.c (coreMQTT)2.8K2.2K
Total estimates10.5K8.6K

Memory Estimation includes coreMQTT library
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.