How to migrate an MQTT application from v3 to 202009.00 and subsequent releases.
The MQTT library has been refactored in 202009.00 and subsequent releases, to use only a single thread, and therefore no longer has any thread synchronization dependencies. New features such as persistent session support and QoS 2 publish delivery have also been added.
The features of the MQTT libraries in v3 and 202009.00 and subsequent releases are defined by the common MQTT 3.1.1 spec; therefore, the two versions are similar.
The following features were present in v3, but removed in 202009.00 and subsequent releases:
aws_iot_mqtt_yield
. In version 202009.00 and subsequent releases, the auto-reconnect feature has been removed. _ENABLE_THREAD_SUPPORT_
macro for multi-threading use cases. Version 202009.00 and subsequent releases does not spawn any threads and therefore, the macro _ENABLE_THREAD_SUPPORT_
has been removed.The following table lists equivalent data types in v3 and 202009.00 and subsequent releases.
Version 3 | Version 202009.00 and subsequent releases | Notes |
---|---|---|
enum QoS | MQTTQoS_t | MQTT Quality of service. |
AWS_IoT_Client | MQTTContext_t | MQTT connection handle. |
IoT_Publish_Message_Params | MQTTPublishInfo_t | Parameters of an MQTT publish. |
IoT_MQTT_Will_Options | MQTTPublishInfo_t | Optional Will parameter of an MQTT connect. |
IoT_Client_Connect_Params | MQTTConnectInfo_t | Parameters of an MQTT connect. |
IoT_Client_Init_Params | None | The members of this struct in v3 handled setup of the network connection. This is handled outside of the MQTT library in 202009.00 and subsequent releases. |
pApplicationHandler_t | MQTTEventCallback_t | Function pointer of application callback to receive incoming data. |
The following table lists equivalent API functions in v3 and 202009.00 and subsequent releases. These functions are the API functions declared in:
Version 3 | Version 202009.00 and subsequent releases | Notes |
---|---|---|
aws_iot_mqtt_init | MQTT_Init | |
aws_iot_mqtt_free | None | 202009.00 and subsequent releases does not allocate any memory and therefore, has nothing to free. |
aws_iot_mqtt_connect | MQTT_Connect | |
aws_iot_mqtt_publish | MQTT_Publish | |
aws_iot_mqtt_subscribe | MQTT_Subscribe | |
aws_iot_mqtt_resubscribe | None | Function removed because auto-reconnect was removed. |
aws_iot_mqtt_unsubscribe | MQTT_Unsubscribe | |
aws_iot_mqtt_disconnect | MQTT_Disconnect | |
aws_iot_mqtt_yield | MQTT_ProcessLoop | MQTT_ReceiveLoop is the equivalent function without any keep-alive mechanism. |
aws_iot_mqtt_attempt_reconnect | None | Function removed because auto-reconnect was removed. |