From 0a5dfd37173e6640ac74d0f0867ecbb2f6558b82 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Thu, 6 Jun 2019 18:28:19 +0530 Subject: [PATCH] mbedtls: add config option for setting debug level Closes https://github.com/espressif/esp-idf/issues/3521 --- components/esp-tls/esp_tls.c | 4 ++-- components/mbedtls/Kconfig | 24 +++++++++++++++++++ .../main/https_mbedtls_example_main.c | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index 094292dd0c..8d2c528ae5 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -327,7 +327,7 @@ static int create_ssl_handle(esp_tls_t *tls, const char *hostname, size_t hostle mbedtls_ssl_conf_rng(&tls->conf, mbedtls_ctr_drbg_random, &tls->ctr_drbg); #ifdef CONFIG_MBEDTLS_DEBUG - mbedtls_esp_enable_debug_log(&tls->conf, 4); + mbedtls_esp_enable_debug_log(&tls->conf, CONFIG_MBEDTLS_DEBUG_LEVEL); #endif if ((ret = mbedtls_ssl_setup(&tls->ssl, &tls->conf)) != 0) { @@ -555,4 +555,4 @@ int esp_tls_conn_http_new_async(const char *url, const esp_tls_cfg_t *cfg, esp_t /* Connect to host */ return esp_tls_conn_new_async(&url[u.field_data[UF_HOST].off], u.field_data[UF_HOST].len, get_port(url, &u), cfg, tls); -} \ No newline at end of file +} diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index 4d1d527fea..91b5c506ea 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -92,6 +92,30 @@ menu "mbedTLS" at runtime in order to enable mbedTLS debug output via the ESP log mechanism. + choice MBEDTLS_DEBUG_LEVEL + bool "Set mbedTLS debugging level" + depends on MBEDTLS_DEBUG + default MBEDTLS_DEBUG_LEVEL_VERBOSE + help + Set mbedTLS debugging level + + config MBEDTLS_DEBUG_LEVEL_WARN + bool "Warning" + config MBEDTLS_DEBUG_LEVEL_INFO + bool "Info" + config MBEDTLS_DEBUG_LEVEL_DEBUG + bool "Debug" + config MBEDTLS_DEBUG_LEVEL_VERBOSE + bool "Verbose" + endchoice + + config MBEDTLS_DEBUG_LEVEL + int + default 1 if MBEDTLS_DEBUG_LEVEL_WARN + default 2 if MBEDTLS_DEBUG_LEVEL_INFO + default 3 if MBEDTLS_DEBUG_LEVEL_DEBUG + default 4 if MBEDTLS_DEBUG_LEVEL_VERBOSE + config MBEDTLS_HARDWARE_AES bool "Enable hardware AES acceleration" default y diff --git a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c index fe2c0bf8b3..29c97e831e 100644 --- a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c +++ b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c @@ -142,7 +142,7 @@ static void https_get_task(void *pvParameters) mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL); mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg); #ifdef CONFIG_MBEDTLS_DEBUG - mbedtls_esp_enable_debug_log(&conf, 4); + mbedtls_esp_enable_debug_log(&conf, CONFIG_MBEDTLS_DEBUG_LEVEL); #endif if ((ret = mbedtls_ssl_setup(&ssl, &conf)) != 0)