Skip to content

Commit

Permalink
Hygiene fix in MQTT demos to log warning for unexpected PINGRESP pack…
Browse files Browse the repository at this point in the history
…et event (FreeRTOS#366)

Update MQTT demos to log warning on receiving PINGRESP packet in event callback
  • Loading branch information
aggarw13 authored Oct 29, 2020
1 parent 559772a commit 832a797
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ void vHandleOtherIncomingPacket( MQTTPacketInfo_t * pxPacketInfo,
case MQTT_PACKET_TYPE_PINGRESP:

/* 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 "
"callback when using MQTT_ProcessLoop.\n\n" ) );
"callback when using MQTT_ProcessLoop.\n" ) );
break;

case MQTT_PACKET_TYPE_PUBACK:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break;

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;

case MQTT_PACKET_TYPE_PUBREC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ static void prvEventCallback( MQTTContext_t * pMqttContext,
case MQTT_PACKET_TYPE_PINGRESP:

/* 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 "
"callback when using MQTT_ProcessLoop.\n" ) );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break;

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;

/* Any other packet type is invalid. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@
*/
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 200U )

#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_SECOND ( 1000U ) /**< @brief Milliseconds per second. */
#define MILLISECONDS_PER_TICK ( MILLISECONDS_PER_SECOND / configTICK_RATE_HZ ) /**< Milliseconds per FreeRTOS tick. */

/*-----------------------------------------------------------*/

Expand Down Expand Up @@ -723,7 +723,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break;

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;

/* Any other packet type is invalid. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ static void prvMQTTProcessResponse( MQTTPacketInfo_t * pxIncomingPacket,
break;

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;

/* Any other packet type is invalid. */
Expand Down

0 comments on commit 832a797

Please sign in to comment.