From 640eac84fa37af91bf40b49f10a97b30e4b7b6f8 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 9 Oct 2019 11:03:26 +0200 Subject: [PATCH] mqtt: updated to latest version to include latest fixes, support for global CA store, extended error structure to receive mqtt specific errors. updated idf ssl example to use this error struct https://github.com/espressif/esp-mqtt/issues/135 --- components/mqtt/esp-mqtt | 2 +- examples/protocols/mqtt/ssl/main/app_main.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/mqtt/esp-mqtt b/components/mqtt/esp-mqtt index fb3d2107c..e3b013e2d 160000 --- a/components/mqtt/esp-mqtt +++ b/components/mqtt/esp-mqtt @@ -1 +1 @@ -Subproject commit fb3d2107cdac440d84f2fab81ea9b5217aa4ba1f +Subproject commit e3b013e2db58124ea68cf7c8f44a8cba6e1572b7 diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index fd0a49d7b..4a1c0142f 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -80,10 +80,14 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) break; case MQTT_EVENT_ERROR: ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); - int mbedtls_err = 0; - esp_err_t err = esp_tls_get_and_clear_last_error(event->error_handle, &mbedtls_err, NULL); - ESP_LOGI(TAG, "Last esp error code: 0x%x", err); - ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err); + if (event->error_handle->error_type == MQTT_ERROR_TYPE_ESP_TLS) { + ESP_LOGI(TAG, "Last error code reported from esp-tls: 0x%x", event->error_handle->esp_tls_last_esp_err); + ESP_LOGI(TAG, "Last tls stack error number: 0x%x", event->error_handle->esp_tls_stack_err); + } else if (event->error_handle->error_type == MQTT_ERROR_TYPE_CONNECTION_REFUSED) { + ESP_LOGI(TAG, "Connection refused error: 0x%x", event->error_handle->connect_return_code); + } else { + ESP_LOGW(TAG, "Unknown error type: 0x%x", event->error_handle->error_type); + } break; default: ESP_LOGI(TAG, "Other event id:%d", event->event_id);