接前一篇文章:ESP32-C3在MQTT访问时出现“transport_base: Poll timeout or error”问题的分析(9)
上一回继续解析process_keepalive函数,重点分析了其中调用的has_timed_out函数,本回继续往下解析。为了便于理解和回顾,再次贴出process_keepalive函数源码,在components\components\mqtt\esp-mqtt\mqtt_client.c中,如下:
static esp_err_t process_keepalive(esp_mqtt_client_handle_t client)
{
if (client->mqtt_state.connection.information.keepalive > 0) {
const uint64_t keepalive_ms = client->mqtt_state.connection.information.keepalive * 1000;
if (client->wait_for_ping_resp == true ) {
if (has_timed_out(client->keepalive_tick, keepalive_ms)) {
ESP_LOGE(TAG, "No PING_RESP, disconnected");
esp_mqtt_abort_connection(