diff --git a/arch/risc-v/src/esp32c3/Kconfig b/arch/risc-v/src/esp32c3/Kconfig index 03b67cd6ec8..1044de2b4fe 100644 --- a/arch/risc-v/src/esp32c3/Kconfig +++ b/arch/risc-v/src/esp32c3/Kconfig @@ -807,6 +807,36 @@ config ESP32C3_WIFI_RECONNECT ---help--- Select this option to enable Wi-Fi to reconnect for station when disconnected. +choice ESP32C3_WIFI_LOG_LEVEL + depends on DEBUG_INFO + prompt "WiFi debug log level" + default WIFI_LOG_LEVEL_INFO + help + The WiFi log is divided into the following levels: ERROR,WARNING,INFO,DEBUG,VERBOSE. + + config WIFI_LOG_LEVEL_NONE + bool "No output" + config WIFI_LOG_LEVEL_ERROR + bool "Error" + config WIFI_LOG_LEVEL_WARN + bool "Warning" + config WIFI_LOG_LEVEL_INFO + bool "Info" + config WIFI_LOG_LEVEL_DEBUG + bool "Debug" + config WIFI_LOG_LEVEL_VERBOSE + bool "Verbose" +endchoice + +config WIFI_LOG_LEVEL + int + default 0 if WIFI_LOG_LEVEL_NONE + default 1 if WIFI_LOG_LEVEL_ERROR + default 2 if WIFI_LOG_LEVEL_WARN + default 3 if WIFI_LOG_LEVEL_INFO + default 4 if WIFI_LOG_LEVEL_DEBUG + default 5 if WIFI_LOG_LEVEL_VERBOSE + endmenu # Wi-Fi configuration menu "BLE Configuration" diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 0cdfe3c2f90..9c866407cf3 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -390,6 +390,7 @@ static int esp_wifi_lock(bool lock); #ifdef ESP32C3_WLAN_HAS_STA static int esp_wifi_sta_connect_wrapper(void); #endif +static void esp_wifi_set_debug_log(void); /**************************************************************************** * Extern Functions declaration @@ -720,6 +721,32 @@ static int esp_wifi_sta_connect_wrapper(void) #endif +/**************************************************************************** + * Name: esp_wifi_set_debug_log + * + * Description: + * Set Wi-Fi log level and module + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp_wifi_set_debug_log(void) +{ + uint32_t g_wifi_log_submodule = WIFI_LOG_SUBMODULE_CONN; + wifi_log_level_t level = WIFI_LOG_INFO; +#ifdef CONFIG_WIFI_LOG_LEVEL + level = CONFIG_WIFI_LOG_LEVEL; +#endif + esp_wifi_internal_set_log_level(level); + esp_wifi_internal_set_log_mod(WIFI_LOG_MODULE_WIFI, + g_wifi_log_submodule, true); +} + /**************************************************************************** * Name: osi_errno_trans * @@ -5107,6 +5134,8 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) return ret; } + esp_wifi_set_debug_log(); + ret = esp_supplicant_init(); if (ret) {