From 5a2c56bf9c9e0c747487532fe95b1fc725ac4213 Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 17 May 2022 08:37:37 +0800 Subject: [PATCH] Cancel all command when MQTT command failed (#814) * Use MQTT Agent provided API, MQTTAgent_CancelAll, to clear queue when MQTT command failed. --- .../Ota_Over_Http_Demo/DemoTasks/OtaOverHttpDemoExample.c | 2 +- .../Ota_Over_Mqtt_Demo/DemoTasks/OtaOverMqttDemoExample.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/DemoTasks/OtaOverHttpDemoExample.c b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/DemoTasks/OtaOverHttpDemoExample.c index 3e09a5979a..3f6bb25ea9 100644 --- a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/DemoTasks/OtaOverHttpDemoExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/DemoTasks/OtaOverHttpDemoExample.c @@ -2132,7 +2132,7 @@ static void prvMQTTAgentTask(void* pParam) xMQTTStatus = MQTTAgent_CommandLoop(&xGlobalMqttAgentContext); /* Clear Agent queue so that no any pending MQTT operations are processed. */ - xQueueReset(xCommandQueue.queue); + MQTTAgent_CancelAll(&xGlobalMqttAgentContext); /* Success is returned for application initiated disconnect or termination. The socket will also be disconnected by the caller. */ if (xMQTTStatus != MQTTSuccess) diff --git a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/DemoTasks/OtaOverMqttDemoExample.c b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/DemoTasks/OtaOverMqttDemoExample.c index 9aa45b05cd..cf9a0ff8f4 100644 --- a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/DemoTasks/OtaOverMqttDemoExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/DemoTasks/OtaOverMqttDemoExample.c @@ -1725,7 +1725,7 @@ static void prvMQTTAgentTask(void* pParam) xMQTTStatus = MQTTAgent_CommandLoop(&xGlobalMqttAgentContext); /* Clear Agent queue so that no any pending MQTT operations are processed. */ - xQueueReset(xCommandQueue.queue); + MQTTAgent_CancelAll(&xGlobalMqttAgentContext); /* Success is returned for application initiated disconnect or termination. The socket will also be disconnected by the caller. */ if (xMQTTStatus != MQTTSuccess)