Hygiene fix in MQTT demos to log warning for unexpected PINGRESP packet event (#366)

Update MQTT demos to log warning on receiving PINGRESP packet in event callback
This commit is contained in:
Archit Aggarwal 2020-10-28 17:41:54 -07:00 committed by GitHub
parent 559772a4db
commit 832a797c69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 9 deletions

View file

@ -469,9 +469,9 @@ void vHandleOtherIncomingPacket( MQTTPacketInfo_t * pxPacketInfo,
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
/* Nothing to be done from application as library handles /* Nothing to be done from application as library handles
* PINGRESP. */ * PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application " LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n\n" ) ); "callback when using MQTT_ProcessLoop.\n" ) );
break; break;
case MQTT_PACKET_TYPE_PUBACK: case MQTT_PACKET_TYPE_PUBACK:

View file

@ -778,7 +778,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break; break;
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
LogInfo( ( "Ping Response successfully received.\r\n" ) );
/* Nothing to be done from application as library handles
* PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n" ) );
break; break;
case MQTT_PACKET_TYPE_PUBREC: case MQTT_PACKET_TYPE_PUBREC:

View file

@ -1716,7 +1716,7 @@ static void prvEventCallback( MQTTContext_t * pMqttContext,
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
/* Nothing to be done from application as library handles /* Nothing to be done from application as library handles
* PINGRESP. */ * PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application " LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n" ) ); "callback when using MQTT_ProcessLoop.\n" ) );
break; break;

View file

@ -902,7 +902,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break; break;
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
LogInfo( ( "Ping Response successfully received.\r\n" ) );
/* Nothing to be done from application as library handles
* PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n" ) );
break; break;
/* Any other packet type is invalid. */ /* Any other packet type is invalid. */

View file

@ -153,8 +153,8 @@
*/ */
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 200U ) #define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 200U )
#define MILLISECONDS_PER_SECOND ( 1000U ) /**< @brief Milliseconds per second. */ #define MILLISECONDS_PER_SECOND ( 1000U ) /**< @brief Milliseconds per second. */
#define MILLISECONDS_PER_TICK ( MILLISECONDS_PER_SECOND / configTICK_RATE_HZ ) /**< Milliseconds per FreeRTOS tick. */ #define MILLISECONDS_PER_TICK ( MILLISECONDS_PER_SECOND / configTICK_RATE_HZ ) /**< Milliseconds per FreeRTOS tick. */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -723,7 +723,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break; break;
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
LogInfo( ( "Ping Response successfully received." ) );
/* Nothing to be done from application as library handles
* PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n" ) );
break; break;
/* Any other packet type is invalid. */ /* Any other packet type is invalid. */

View file

@ -621,7 +621,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break; break;
case MQTT_PACKET_TYPE_PINGRESP: case MQTT_PACKET_TYPE_PINGRESP:
LogInfo( ( "Ping Response successfully received.\r\n" ) );
/* Nothing to be done from application as library handles
* PINGRESP with the use of MQTT_ProcessLoop API function. */
LogWarn( ( "PINGRESP should not be handled by the application "
"callback when using MQTT_ProcessLoop.\n" ) );
break; break;
/* Any other packet type is invalid. */ /* Any other packet type is invalid. */