Skip to content

Commit a54abb1

Browse files
author
ding huan
committed
fix(conn): wifi connect before connected status
1 parent 2fb938c commit a54abb1

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

components/esp_wifi/test_apps/wifi_connect/main/app_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void setUp(void)
3737
void tearDown(void)
3838
{
3939
ESP_ERROR_CHECK(esp_wifi_deinit());
40+
vTaskDelay(500 / portTICK_PERIOD_MS);
4041
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
4142
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
4243
check_leak(before_free_8bit, after_free_8bit, "8BIT");

components/esp_wifi/test_apps/wifi_connect/main/test_wifi_conn.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*
@@ -272,19 +272,18 @@ static void esp_wifi_connect_first_time(void)
272272
// make sure softap has started
273273
vTaskDelay(1000 / portTICK_PERIOD_MS);
274274

275-
wifi_config_t w_config;
276-
memset(&w_config, 0, sizeof(w_config));
277-
memcpy(w_config.sta.ssid, TEST_DEFAULT_SSID, strlen(TEST_DEFAULT_SSID));
278-
memcpy(w_config.sta.password, TEST_DEFAULT_PWD, strlen(TEST_DEFAULT_PWD));
279-
w_config.sta.channel = 1;
275+
wifi_config_t w_config = {
276+
.sta.ssid = TEST_DEFAULT_SSID,
277+
.sta.password = "invalid_password",
278+
.sta.channel = 1,
279+
};
280280

281281
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;
282282

283283
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &w_config));
284284
ESP_LOGI(TAG, "start esp_wifi_connect first time: %s", TEST_DEFAULT_SSID);
285285
TEST_ESP_OK(esp_wifi_connect());
286286
}
287-
288287
static void test_wifi_connect_at_scan_phase(void)
289288
{
290289

@@ -304,8 +303,8 @@ static void test_wifi_connect_before_connected_phase(void)
304303

305304
esp_wifi_connect_first_time();
306305

307-
// connect before connected
308-
vTaskDelay(730 / portTICK_PERIOD_MS);
306+
// connect before connected from channel 1 to 6 need 720ms
307+
vTaskDelay(725 / portTICK_PERIOD_MS);
309308
ESP_LOGI(TAG, "connect when first connect after scan before connected");
310309
TEST_ESP_ERR(ESP_ERR_WIFI_CONN, esp_wifi_connect());
311310
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;

components/esp_wifi/test_apps/wifi_connect/sdkconfig.defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# ignore task watchdog triggered by unity_run_menu
33
CONFIG_ESP_TASK_WDT_EN=n
44
CONFIG_ESP_WIFI_BSS_MAX_IDLE_SUPPORT=y
5+
CONFIG_FREERTOS_HZ=1000

0 commit comments

Comments
 (0)