Skip to content

Commit

Permalink
Fix stat reset for ping response
Browse files Browse the repository at this point in the history
  • Loading branch information
embhorn committed Jan 21, 2025
1 parent d5b9743 commit 55129e3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,9 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
client->packet.buf_len, packet_type, packet_id);
#endif

mms_stat->read = MQTT_MSG_PAYLOAD;
if (packet_type != MQTT_PACKET_TYPE_PING_RESP) {
mms_stat->read = MQTT_MSG_PAYLOAD;
}
}
FALL_THROUGH;

Expand Down Expand Up @@ -1446,15 +1448,9 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
break;
} /* switch (mms_stat->ack) */

#ifdef WOLFMQTT_DEBUG_CLIENT
if (rc != MQTT_CODE_CONTINUE) {
PRINTF("MqttClient_WaitType: rc %d, state %d-%d-%d",
rc, mms_stat->read, mms_stat->write, mms_stat->ack);
}
#endif

/* no data read or ack done, then reset state */
if (mms_stat->read == MQTT_MSG_WAIT) {
if (mms_stat->read == MQTT_MSG_WAIT ||
mms_stat->read == MQTT_MSG_HEADER) {
mms_stat->read = MQTT_MSG_BEGIN;
}

Expand Down Expand Up @@ -1507,6 +1503,13 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
MQTT_TRACE_MSG("Wait Again");
goto wait_again;
}
#ifdef WOLFMQTT_DEBUG_CLIENT
if (rc != MQTT_CODE_CONTINUE) {
PRINTF("MqttClient_WaitType: rc %d, state %d-%d-%d",
rc, mms_stat->read, mms_stat->write, mms_stat->ack);
}
#endif


return rc;
}
Expand Down

0 comments on commit 55129e3

Please sign in to comment.