disable scan time set by esp_wifi_scan_start

This commit is contained in:
ding huan 2023-11-14 13:52:55 +08:00
parent 2542b74edd
commit 856daf8a35

View File

@ -38,7 +38,6 @@
#define GOT_IP_EVENT 0x00000001 #define GOT_IP_EVENT 0x00000001
#define DISCONNECT_EVENT 0x00000002 #define DISCONNECT_EVENT 0x00000002
#define STA_CONNECTED_EVENT 0x00000004 #define STA_CONNECTED_EVENT 0x00000004
#define SCAN_DONE_EVENT 0x00000008
#define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001 #define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001
@ -67,13 +66,6 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
} }
break; break;
case WIFI_EVENT_SCAN_DONE:
ESP_LOGI(TAG, "WIFI_EVENT_STA_SCAN DONE");
if (wifi_events) {
xEventGroupSetBits(wifi_events, SCAN_DONE_EVENT);
}
break;
case WIFI_EVENT_STA_DISCONNECTED: case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED"); ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *)event_data; wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *)event_data;
@ -381,32 +373,6 @@ TEST_CASE_MULTIPLE_DEVICES("test wifi retain connection for 60s", "[wifi][test_e
// single core have issue as WIFIBUG-92 // single core have issue as WIFIBUG-92
#if !CONFIG_FREERTOS_UNICORE #if !CONFIG_FREERTOS_UNICORE
static void wifi_scan(void)
{
uint16_t number = 0;
uint8_t *ssid = (uint8_t *)DEFAULT_SSID;
wifi_ap_record_t *ap_info;
wifi_scan_config_t scan_config;
memset(&scan_config, 0, sizeof(wifi_scan_config_t));
scan_config.ssid = ssid;
scan_config.scan_time.active.min = 120;
scan_config.scan_time.active.max = 120;
TEST_ESP_OK(esp_wifi_scan_start(&scan_config, true));
TEST_ESP_OK(esp_wifi_scan_get_ap_num(&number));
ap_info = (wifi_ap_record_t *)malloc(number * sizeof(wifi_ap_record_t));
TEST_ASSERT_NOT_NULL(ap_info);
memset(ap_info, 0, sizeof(wifi_ap_record_t));
TEST_ESP_OK(esp_wifi_scan_get_ap_records(&number, ap_info));
for (int i = 0; i < number; i++) {
ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid);
ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi);
ESP_LOGI(TAG, "Channel \t\t%d\n", ap_info[i].primary);
ESP_LOGI(TAG, "Mac \t\t"MACSTR, MAC2STR(ap_info[i].bssid));
}
free(ap_info);
}
static void wifi_connect(void) static void wifi_connect(void)
{ {
EventBits_t bits; EventBits_t bits;
@ -425,16 +391,11 @@ static void wifi_connect(void)
static void esp_wifi_connect_first_time(void) static void esp_wifi_connect_first_time(void)
{ {
EventBits_t bits;
test_case_uses_tcpip(); test_case_uses_tcpip();
start_wifi_as_sta(); start_wifi_as_sta();
// make sure softap has started // make sure softap has started
vTaskDelay(1000/portTICK_PERIOD_MS); vTaskDelay(1000/portTICK_PERIOD_MS);
// call wifi_scan to set scan_time for internal scan in esp_wifi_connect
wifi_scan();
bits = xEventGroupWaitBits(wifi_events, SCAN_DONE_EVENT, pdTRUE, pdFALSE, 5000/portTICK_PERIOD_MS);
TEST_ASSERT(bits & SCAN_DONE_EVENT);
wifi_config_t w_config; wifi_config_t w_config;
memset(&w_config, 0, sizeof(w_config)); memset(&w_config, 0, sizeof(w_config));
memcpy(w_config.sta.ssid, DEFAULT_SSID, strlen(DEFAULT_SSID)); memcpy(w_config.sta.ssid, DEFAULT_SSID, strlen(DEFAULT_SSID));