mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2025-06-29 13:27:08 +08:00
Adds error messages for AWS demo mqtt helpers + misc fixes (#440)
Switch MQTT helpers to logging error message instead of error code. Adds time parameter to xProccessLoop so defender demo does not wait extra time. Fixes some incorrect returns in metrics_collector.c
This commit is contained in:
47
FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c
Executable file → Normal file
47
FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c
Executable file → Normal file
@ -558,9 +558,9 @@ static BaseType_t xHandlePublishResend( MQTTContext_t * pxMqttContext )
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogError( ( "Sending duplicate PUBLISH for packet id %u "
|
||||
" failed with status %u.",
|
||||
" failed with status %s.",
|
||||
outgoingPublishPackets[ ucIndex ].packetId,
|
||||
xMQTTStatus ) );
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
xReturnStatus = pdFAIL;
|
||||
break;
|
||||
}
|
||||
@ -620,7 +620,8 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext,
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
xReturnStatus = pdFAIL;
|
||||
LogError( ( "MQTT init failed with status %u.", xMQTTStatus ) );
|
||||
LogError( ( "MQTT init failed with status %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -673,7 +674,8 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext,
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
xReturnStatus = pdFAIL;
|
||||
LogError( ( "Connection with MQTT broker failed with status %u.", xMQTTStatus ) );
|
||||
LogError( ( "Connection with MQTT broker failed with status %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -735,8 +737,8 @@ BaseType_t xDisconnectMqttSession( MQTTContext_t * pxMqttContext,
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogError( ( "Sending MQTT DISCONNECT failed with status=%u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "Sending MQTT DISCONNECT failed with status=%s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
xReturnStatus = pdFAIL;
|
||||
}
|
||||
}
|
||||
@ -780,8 +782,8 @@ BaseType_t xSubscribeToTopic( MQTTContext_t * pxMqttContext,
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogError( ( "Failed to send SUBSCRIBE packet to broker with error = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "Failed to send SUBSCRIBE packet to broker with error = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
xReturnStatus = pdFAIL;
|
||||
}
|
||||
else
|
||||
@ -802,8 +804,8 @@ BaseType_t xSubscribeToTopic( MQTTContext_t * pxMqttContext,
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
xReturnStatus = pdFAIL;
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -843,8 +845,8 @@ BaseType_t xUnsubscribeFromTopic( MQTTContext_t * pxMqttContext,
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogError( ( "Failed to send UNSUBSCRIBE packet to broker with error = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "Failed to send UNSUBSCRIBE packet to broker with error = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
xReturnStatus = pdFAIL;
|
||||
}
|
||||
else
|
||||
@ -859,8 +861,8 @@ BaseType_t xUnsubscribeFromTopic( MQTTContext_t * pxMqttContext,
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
xReturnStatus = pdFAIL;
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -913,8 +915,8 @@ BaseType_t xPublishToTopic( MQTTContext_t * pxMqttContext,
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogError( ( "Failed to send PUBLISH packet to broker with error = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "Failed to send PUBLISH packet to broker with error = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
vCleanupOutgoingPublishAt( ucPublishIndex );
|
||||
xReturnStatus = pdFAIL;
|
||||
}
|
||||
@ -935,8 +937,8 @@ BaseType_t xPublishToTopic( MQTTContext_t * pxMqttContext,
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogWarn( ( "MQTT_ProcessLoop returned with status = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
xReturnStatus = pdFAIL;
|
||||
}
|
||||
}
|
||||
@ -947,17 +949,18 @@ BaseType_t xPublishToTopic( MQTTContext_t * pxMqttContext,
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xProcessLoop( MQTTContext_t * pxMqttContext )
|
||||
BaseType_t xProcessLoop( MQTTContext_t * pxMqttContext,
|
||||
uint32_t ulTimeoutMs )
|
||||
{
|
||||
BaseType_t xReturnStatus = pdFAIL;
|
||||
MQTTStatus_t xMQTTStatus = MQTTSuccess;
|
||||
|
||||
xMQTTStatus = MQTT_ProcessLoop( pxMqttContext, mqttexamplePROCESS_LOOP_TIMEOUT_MS );
|
||||
xMQTTStatus = MQTT_ProcessLoop( pxMqttContext, ulTimeoutMs );
|
||||
|
||||
if( xMQTTStatus != MQTTSuccess )
|
||||
{
|
||||
LogWarn( ( "MQTT_ProcessLoop returned with status = %u.",
|
||||
xMQTTStatus ) );
|
||||
LogError( ( "MQTT_ProcessLoop returned with status = %s.",
|
||||
MQTT_Status_strerror( xMQTTStatus ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user