diff --git a/examples/common_components/protocol_examples_common/Kconfig.projbuild b/examples/common_components/protocol_examples_common/Kconfig.projbuild index 25fb188d7d..8b4d13980a 100644 --- a/examples/common_components/protocol_examples_common/Kconfig.projbuild +++ b/examples/common_components/protocol_examples_common/Kconfig.projbuild @@ -46,6 +46,7 @@ menu "Example Connection Configuration" help Set the Maximum retry to avoid station reconnecting to the AP unlimited, in case the AP is really inexistent. + Set to -1 for infinite retries. choice EXAMPLE_WIFI_SCAN_METHOD prompt "WiFi Scan Method" diff --git a/examples/common_components/protocol_examples_common/wifi_connect.c b/examples/common_components/protocol_examples_common/wifi_connect.c index 1bfc1b35f4..fb7ef800c3 100644 --- a/examples/common_components/protocol_examples_common/wifi_connect.c +++ b/examples/common_components/protocol_examples_common/wifi_connect.c @@ -32,7 +32,7 @@ static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event int32_t event_id, void *event_data) { s_retry_num++; - if (s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) { + if (CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY >= 0 && s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) { ESP_LOGI(TAG, "WiFi Connect failed %d times, stop reconnect.", s_retry_num); /* let example_wifi_sta_do_connect() return */ if (s_semph_get_ip_addrs) { @@ -176,7 +176,7 @@ esp_err_t example_wifi_sta_do_connect(wifi_config_t wifi_config, bool wait) #if CONFIG_EXAMPLE_CONNECT_IPV6 xSemaphoreTake(s_semph_get_ip6_addrs, portMAX_DELAY); #endif - if (s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) { + if (CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY >= 0 && s_retry_num > CONFIG_EXAMPLE_WIFI_CONN_MAX_RETRY) { return ESP_FAIL; } }