Просмотр исходного кода

Merge branch 'feature/add_task_wrappers' into 'master'

wpa_supplicant: Add osi layer for FreeRTOS calls

Closes WIFI-2996

See merge request espressif/esp-idf!11734
Jiang Jiang Jian 3 лет назад
Родитель
Сommit
8efa4d64e0

+ 14 - 13
components/esp_wifi/include/esp_private/esp_wifi_private.h

@@ -1,16 +1,8 @@
-// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
+/*
+ * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 #ifndef _ESP_WIFI_PRIVATE_H
 #define _ESP_WIFI_PRIVATE_H
 
@@ -21,5 +13,14 @@
 #include "esp_wifi_crypto_types.h"
 #include "esp_private/wifi_os_adapter.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WIFI_OSI_FUNCS_INITIALIZER() &g_wifi_osi_funcs
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _ESP_WIFI_PRIVATE_H */

+ 15 - 12
components/wpa_supplicant/esp_supplicant/src/esp_common.c

@@ -27,9 +27,12 @@
 struct wpa_supplicant g_wpa_supp;
 
 #ifdef CONFIG_SUPPLICANT_TASK
-static TaskHandle_t s_supplicant_task_hdl = NULL;
+static void *s_supplicant_task_hdl = NULL;
 static void *s_supplicant_evt_queue = NULL;
 static void *s_supplicant_api_lock = NULL;
+#define SUPPLICANT_API_LOCK() os_mutex_lock(s_supplicant_api_lock)
+#define SUPPLICANT_API_UNLOCK() os_mutex_unlock(s_supplicant_api_lock)
+#define SUPPLICANT_TASK_STACK_SIZE (6144 + TASK_STACK_SIZE_ADD)
 
 static int handle_action_frm(u8 *frame, size_t len,
 			     u8 *sender, u32 rssi, u8 channel)
@@ -105,7 +108,7 @@ static void btm_rrm_task(void *pvParameters)
 	bool task_del = false;
 
 	while(1) {
-		if (xQueueReceive(s_supplicant_evt_queue, &evt, portMAX_DELAY) != pdTRUE)
+		if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE)
 			continue;
 
 		/* event validation failed */
@@ -139,16 +142,16 @@ static void btm_rrm_task(void *pvParameters)
 			break;
 	}
 
-	vQueueDelete(s_supplicant_evt_queue);
+	os_queue_delete(s_supplicant_evt_queue);
 	s_supplicant_evt_queue = NULL;
 
 	if (s_supplicant_api_lock) {
-		vSemaphoreDelete(s_supplicant_api_lock);
+		os_semphr_delete(s_supplicant_api_lock);
 		s_supplicant_api_lock = NULL;
 	}
 
 	/* At this point, we completed */
-	vTaskDelete(NULL);
+	os_task_delete(NULL);
 }
 #endif
 
@@ -346,22 +349,22 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb)
 	int ret = 0;
 
 #ifdef CONFIG_SUPPLICANT_TASK
-	s_supplicant_api_lock = xSemaphoreCreateRecursiveMutex();
+	s_supplicant_api_lock = os_recursive_mutex_create();
 	if (!s_supplicant_api_lock) {
 		wpa_printf(MSG_ERROR, "%s: failed to create Supplicant API lock", __func__);
 		ret = -1;
 		goto err;
 	}
 
-	s_supplicant_evt_queue = xQueueCreate(3, sizeof(supplicant_event_t));
+	s_supplicant_evt_queue = os_queue_create(3, sizeof(supplicant_event_t));
 
 	if (!s_supplicant_evt_queue) {
 		wpa_printf(MSG_ERROR, "%s: failed to create Supplicant event queue", __func__);
 		ret = -1;
 		goto err;
 	}
-	ret = xTaskCreate(btm_rrm_task, "btm_rrm_t", SUPPLICANT_TASK_STACK_SIZE, NULL, 2, &s_supplicant_task_hdl);
-	if (ret != pdPASS) {
+	ret = os_task_create(btm_rrm_task, "btm_rrm_t", SUPPLICANT_TASK_STACK_SIZE, NULL, 2, &s_supplicant_task_hdl);
+	if (ret != TRUE) {
 		wpa_printf(MSG_ERROR, "btm: failed to create task");
 		ret = -1;
 		goto err;
@@ -417,11 +420,11 @@ void esp_supplicant_common_deinit(void)
 #ifdef CONFIG_SUPPLICANT_TASK
 	if (!s_supplicant_task_hdl && esp_supplicant_post_evt(SIG_SUPPLICANT_DEL_TASK, 0) != 0) {
 		if (s_supplicant_evt_queue) {
-			vQueueDelete(s_supplicant_evt_queue);
+			os_queue_delete(s_supplicant_evt_queue);
 			s_supplicant_evt_queue = NULL;
 		}
 		if (s_supplicant_api_lock) {
-			vSemaphoreDelete(s_supplicant_api_lock);
+			os_semphr_delete(s_supplicant_api_lock);
 			s_supplicant_api_lock = NULL;
 		}
 	}
@@ -833,7 +836,7 @@ int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data)
 		os_free(evt);
 		return -1;
 	}
-	if (xQueueSend(s_supplicant_evt_queue, &evt, 10 / portTICK_PERIOD_MS ) != pdPASS) {
+	if (os_queue_send(s_supplicant_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
 		SUPPLICANT_API_UNLOCK();
 		os_free(evt);
 		return -1;

+ 2 - 5
components/wpa_supplicant/esp_supplicant/src/esp_common_i.h

@@ -21,15 +21,13 @@ struct ieee_mgmt_frame {
 	u8 payload[0];
 };
 
+int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data);
+
 typedef struct {
     uint32_t id;
     uint32_t data;
 } supplicant_event_t;
 
-#define SUPPLICANT_API_LOCK() xSemaphoreTakeRecursive(s_supplicant_api_lock, portMAX_DELAY)
-#define SUPPLICANT_API_UNLOCK() xSemaphoreGiveRecursive(s_supplicant_api_lock)
-
-#define SUPPLICANT_TASK_STACK_SIZE (6144 + TASK_STACK_SIZE_ADD)
 enum SIG_SUPPLICANT {
 	SIG_SUPPLICANT_RX_ACTION,
 	SIG_SUPPLICANT_SCAN_DONE,
@@ -37,7 +35,6 @@ enum SIG_SUPPLICANT {
 	SIG_SUPPLICANT_MAX,
 };
 
-int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data);
 void esp_get_tx_power(uint8_t *tx_power);
 #ifdef CONFIG_MBO
 bool mbo_bss_profile_match(u8 *bssid);

+ 15 - 17
components/wpa_supplicant/esp_supplicant/src/esp_dpp.c

@@ -4,21 +4,19 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "freertos/queue.h"
-#include "freertos/semphr.h"
+#include "utils/includes.h"
+#include "utils/common.h"
+#include "common/defs.h"
 
 #include "esp_dpp_i.h"
 #include "esp_dpp.h"
 #include "esp_wpa.h"
-#include "esp_timer.h"
 #include "esp_event.h"
 #include "esp_wifi.h"
 #include "common/ieee802_11_defs.h"
 
 #ifdef CONFIG_DPP
-static TaskHandle_t s_dpp_task_hdl = NULL;
+static void *s_dpp_task_hdl = NULL;
 static void *s_dpp_evt_queue = NULL;
 static void *s_dpp_api_lock = NULL;
 
@@ -27,8 +25,8 @@ static int s_dpp_auth_retries;
 struct esp_dpp_context_t s_dpp_ctx;
 static wifi_action_rx_cb_t s_action_rx_cb = esp_supp_rx_action;
 
-#define DPP_API_LOCK() xSemaphoreTakeRecursive(s_dpp_api_lock, portMAX_DELAY)
-#define DPP_API_UNLOCK() xSemaphoreGiveRecursive(s_dpp_api_lock)
+#define DPP_API_LOCK() os_mutex_lock(s_dpp_api_lock)
+#define DPP_API_UNLOCK() os_mutex_unlock(s_dpp_api_lock)
 
 struct action_rx_param {
     u8 sa[ETH_ALEN];
@@ -55,7 +53,7 @@ static int esp_dpp_post_evt(uint32_t evt_id, uint32_t data)
         ret = ESP_ERR_DPP_FAILURE;
         goto end;
     }
-    if (xQueueSend(s_dpp_evt_queue, &evt, 10 / portTICK_PERIOD_MS ) != pdPASS) {
+    if (os_queue_send(s_dpp_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
         DPP_API_UNLOCK();
         ret = ESP_ERR_DPP_FAILURE;
         goto end;
@@ -348,7 +346,7 @@ static void esp_dpp_task(void *pvParameters )
     bool task_del = false;
 
     for (;;) {
-        if (xQueueReceive(s_dpp_evt_queue, &evt, portMAX_DELAY) == pdTRUE) {
+        if (os_queue_recv(s_dpp_evt_queue, &evt, OS_BLOCK) == TRUE) {
             if (evt->id >= SIG_DPP_MAX) {
                 os_free(evt);
                 continue;
@@ -399,16 +397,16 @@ static void esp_dpp_task(void *pvParameters )
         }
     }
 
-    vQueueDelete(s_dpp_evt_queue);
+    os_queue_delete(s_dpp_evt_queue);
     s_dpp_evt_queue = NULL;
 
     if (s_dpp_api_lock) {
-        vSemaphoreDelete(s_dpp_api_lock);
+        os_semphr_delete(s_dpp_api_lock);
         s_dpp_api_lock = NULL;
     }
 
     /* At this point, we completed */
-    vTaskDelete(NULL);
+    os_task_delete(NULL);
 }
 
 int esp_supp_rx_action(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel)
@@ -610,14 +608,14 @@ esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb)
     s_dpp_ctx.dpp_global = dpp_global_init(&cfg);
 
     s_dpp_stop_listening = false;
-    s_dpp_evt_queue = xQueueCreate(3, sizeof(dpp_event_t));
-    ret = xTaskCreate(esp_dpp_task, "dppT", DPP_TASK_STACK_SIZE, NULL, 2, &s_dpp_task_hdl);
-    if (ret != pdPASS) {
+    s_dpp_evt_queue = os_queue_create(3, sizeof(dpp_event_t));
+    ret = os_task_create(esp_dpp_task, "dppT", DPP_TASK_STACK_SIZE, NULL, 2, &s_dpp_task_hdl);
+    if (ret != TRUE) {
         wpa_printf(MSG_ERROR, "DPP: failed to create task");
         return ESP_FAIL;
     }
 
-    s_dpp_api_lock = xSemaphoreCreateRecursiveMutex();
+    s_dpp_api_lock = os_recursive_mutex_create();
     if (!s_dpp_api_lock) {
         esp_supp_dpp_deinit();
         wpa_printf(MSG_ERROR, "DPP: dpp_init: failed to create DPP API lock");

+ 22 - 30
components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c

@@ -6,11 +6,6 @@
 
 #include <string.h>
 
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "freertos/queue.h"
-#include "freertos/semphr.h"
-
 #include "esp_err.h"
 
 #include "utils/includes.h"
@@ -44,8 +39,8 @@
 
 #define WPA2_VERSION    "v2.0"
 
-#define DATA_MUTEX_TAKE() xSemaphoreTakeRecursive(s_wpa2_data_lock,portMAX_DELAY)
-#define DATA_MUTEX_GIVE() xSemaphoreGiveRecursive(s_wpa2_data_lock)
+#define DATA_MUTEX_TAKE() os_mutex_lock(s_wpa2_data_lock)
+#define DATA_MUTEX_GIVE() os_mutex_unlock(s_wpa2_data_lock)
 
 //length of the string "fast_provisioning={0/1/2} "
 #define FAST_PROVISIONING_CONFIG_STR_LEN 20
@@ -68,7 +63,7 @@ static int wpa2_start_eapol_internal(void);
 int wpa2_post(uint32_t sig, uint32_t par);
 
 #ifdef USE_WPA2_TASK
-static TaskHandle_t s_wpa2_task_hdl = NULL;
+static void *s_wpa2_task_hdl = NULL;
 static void *s_wpa2_queue = NULL;
 static wpa2_state_t s_wpa2_state = WPA2_STATE_DISABLED;
 static void *s_wpa2_api_lock = NULL;
@@ -78,20 +73,20 @@ static bool s_disable_time_check = true;
 static void wpa2_api_lock(void)
 {
     if (s_wpa2_api_lock == NULL) {
-        s_wpa2_api_lock = xSemaphoreCreateRecursiveMutex();
+        s_wpa2_api_lock = os_recursive_mutex_create();
         if (!s_wpa2_api_lock) {
             wpa_printf(MSG_ERROR, "WPA2: failed to create wpa2 api lock");
             return;
         }
     }
 
-    xSemaphoreTakeRecursive(s_wpa2_api_lock, portMAX_DELAY);
+    os_mutex_lock(s_wpa2_api_lock);
 }
 
 static void wpa2_api_unlock(void)
 {
     if (s_wpa2_api_lock) {
-        xSemaphoreGiveRecursive(s_wpa2_api_lock);
+        os_mutex_unlock(s_wpa2_api_lock);
     }
 }
 
@@ -122,7 +117,7 @@ static void wpa2_set_eap_state(wpa2_ent_eap_state_t state)
 
 static inline void wpa2_task_delete(void *arg)
 {
-    void *my_task_hdl = xTaskGetCurrentTaskHandle();
+    void *my_task_hdl = os_task_get_current_task();
     int ret = ESP_OK;
 
     if (my_task_hdl == s_wpa2_task_hdl) {
@@ -198,7 +193,7 @@ void wpa2_task(void *pvParameters )
     }
 
     for (;;) {
-        if ( pdPASS == xQueueReceive(s_wpa2_queue, &e, portMAX_DELAY) ) {
+        if ( TRUE == os_queue_recv(s_wpa2_queue, &e, OS_BLOCK) ) {
             if (e->sig < SIG_WPA2_MAX) {
                 DATA_MUTEX_TAKE();
                 if(sm->wpa2_sig_cnt[e->sig]) {
@@ -236,7 +231,7 @@ void wpa2_task(void *pvParameters )
         } else {
             if (s_wifi_wpa2_sync_sem) {
                 wpa_printf(MSG_DEBUG, "WPA2: wifi->wpa2 api completed sig(%d)", e->sig);
-                xSemaphoreGive(s_wifi_wpa2_sync_sem);
+                os_semphr_give(s_wifi_wpa2_sync_sem);
             } else {
                 wpa_printf(MSG_ERROR, "WPA2: null wifi->wpa2 sync sem");
             }
@@ -244,18 +239,18 @@ void wpa2_task(void *pvParameters )
     }
 
     wpa_printf(MSG_DEBUG, "WPA2: queue deleted");
-    vQueueDelete(s_wpa2_queue);
+    os_queue_delete(s_wpa2_queue);
     wpa_printf(MSG_DEBUG, "WPA2: task deleted");
     s_wpa2_queue = NULL;
     if (s_wifi_wpa2_sync_sem) {
         wpa_printf(MSG_DEBUG, "WPA2: wifi->wpa2 api completed sig(%d)", e->sig);
-        xSemaphoreGive(s_wifi_wpa2_sync_sem);
+        os_semphr_give(s_wifi_wpa2_sync_sem);
     } else {
         wpa_printf(MSG_ERROR, "WPA2: null wifi->wpa2 sync sem");
     }
 
     /* At this point, we completed */
-    vTaskDelete(NULL);
+    os_task_delete(NULL);
 }
 
 int wpa2_post(uint32_t sig, uint32_t par)
@@ -281,12 +276,12 @@ int wpa2_post(uint32_t sig, uint32_t par)
         DATA_MUTEX_GIVE();
         evt->sig = sig;
         evt->par = par;
-        if ( xQueueSend(s_wpa2_queue, &evt, 10 / portTICK_PERIOD_MS ) != pdPASS) {
+        if (os_queue_send(s_wpa2_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
             wpa_printf(MSG_ERROR, "WPA2: Q S E");
             return ESP_FAIL;
         } else {
             if (s_wifi_wpa2_sync_sem) {
-                xSemaphoreTake(s_wifi_wpa2_sync_sem, portMAX_DELAY);
+                os_semphr_take(s_wifi_wpa2_sync_sem, OS_BLOCK);
                 wpa_printf(MSG_DEBUG, "WPA2: wpa2 api return, sm->state(%d)", sm->finish_state);
             } else {
                 wpa_printf(MSG_ERROR, "WPA2: null wifi->wpa2 sync sem");
@@ -693,7 +688,7 @@ static int eap_peer_sm_init(void)
     }
 
     gEapSm = sm;
-    s_wpa2_data_lock = xSemaphoreCreateRecursiveMutex();
+    s_wpa2_data_lock = os_recursive_mutex_create();
     if (!s_wpa2_data_lock) {
         wpa_printf(MSG_ERROR, "wpa2 eap_peer_sm_init: failed to alloc data lock");
         ret = ESP_ERR_NO_MEM;
@@ -728,14 +723,14 @@ static int eap_peer_sm_init(void)
 
     gEapSm = sm;
 #ifdef USE_WPA2_TASK
-    s_wpa2_queue = xQueueCreate(SIG_WPA2_MAX, sizeof(s_wpa2_queue));
-    ret = xTaskCreate(wpa2_task, "wpa2T", WPA2_TASK_STACK_SIZE, NULL, 2, &s_wpa2_task_hdl);
-    if (ret != pdPASS) {
+    s_wpa2_queue = os_queue_create(SIG_WPA2_MAX, sizeof(s_wpa2_queue));
+    ret = os_task_create(wpa2_task, "wpa2T", WPA2_TASK_STACK_SIZE, NULL, 2, &s_wpa2_task_hdl);
+    if (ret != TRUE) {
         wpa_printf(MSG_ERROR, "wps enable: failed to create task");
         ret = ESP_FAIL;
         goto _err;
     }
-    s_wifi_wpa2_sync_sem = xSemaphoreCreateCounting(1, 0);
+    s_wifi_wpa2_sync_sem = os_semphr_create(1, 0);
     if (!s_wifi_wpa2_sync_sem) {
         wpa_printf(MSG_ERROR, "WPA2: failed create wifi wpa2 task sync sem");
         ret = ESP_FAIL;
@@ -780,18 +775,18 @@ static void eap_peer_sm_deinit(void)
     }
 
     if (s_wifi_wpa2_sync_sem) {
-        vSemaphoreDelete(s_wifi_wpa2_sync_sem);
+        os_semphr_delete(s_wifi_wpa2_sync_sem);
         s_wifi_wpa2_sync_sem = NULL;
     }
 
     if (s_wpa2_data_lock) {
-        vSemaphoreDelete(s_wpa2_data_lock);
+        os_semphr_delete(s_wpa2_data_lock);
         s_wpa2_data_lock = NULL;
         wpa_printf(MSG_DEBUG, "wpa2 eap_peer_sm_deinit: free data lock");
     }
 
     if (s_wpa2_queue) {
-        vQueueDelete(s_wpa2_queue);
+        os_queue_delete(s_wpa2_queue);
         s_wpa2_queue = NULL;
     }
     os_free(sm);
@@ -866,9 +861,6 @@ esp_err_t esp_wifi_sta_wpa2_ent_disable_fn(void *param)
         eap_peer_sm_deinit();
     }
 
-#ifdef USE_WPA2_TASK
-#endif
-
 #ifdef EAP_PEER_METHOD
     eap_peer_unregister_methods();
 #endif

+ 6 - 0
components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c

@@ -38,6 +38,8 @@
 #include "ap/sta_info.h"
 #include "wps/wps_defs.h"
 
+const wifi_osi_funcs_t *wifi_funcs;
+
 void  wpa_install_key(enum wpa_alg alg, u8 *addr, int key_idx, int set_tx,
                       u8 *seq, size_t seq_len, u8 *key, size_t key_len, enum key_flag key_flag)
 {
@@ -301,6 +303,10 @@ int esp_supplicant_init(void)
     int ret = ESP_OK;
     struct wpa_funcs *wpa_cb;
 
+    wifi_funcs = WIFI_OSI_FUNCS_INITIALIZER();
+    if (!wifi_funcs) {
+        return ESP_ERR_NOT_FOUND;
+    }
     wpa_cb = (struct wpa_funcs *)os_zalloc(sizeof(struct wpa_funcs));
     if (!wpa_cb) {
         return ESP_ERR_NO_MEM;

+ 74 - 80
components/wpa_supplicant/esp_supplicant/src/esp_wps.c

@@ -6,11 +6,9 @@
 
 #include <string.h>
 
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "freertos/queue.h"
-#include "freertos/semphr.h"
 #include "utils/includes.h"
+#include "common.h"
+#include "eloop.h"
 #include "rsn_supp/wpa.h"
 #include "utils/common.h"
 #include "common/eapol_common.h"
@@ -48,7 +46,7 @@ typedef struct {
     int ret; /* return value */
 } wps_ioctl_param_t;
 
-static TaskHandle_t s_wps_task_hdl = NULL;
+static void *s_wps_task_hdl = NULL;
 static void *s_wps_queue = NULL;
 static void *s_wps_data_lock = NULL;
 static void *s_wps_task_create_sem = NULL;
@@ -57,7 +55,7 @@ static uint8_t s_wps_sig_cnt[SIG_WPS_NUM] = {0};
 #endif
 
 void wifi_wps_scan_done(void *arg, STATUS status);
-void wifi_wps_scan(void);
+void wifi_wps_scan(void *data, void *user_ctx);
 int wifi_station_wps_start(void);
 int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len);
 void wifi_wps_start_internal(void);
@@ -70,6 +68,11 @@ void wifi_wps_scan_internal(void);
 void wifi_station_wps_eapol_start_handle_internal(void);
 void wps_add_discard_ap(u8 *bssid);
 
+void wifi_station_wps_msg_timeout(void *data, void *user_ctx);
+void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);
+void wifi_station_wps_success(void *data, void *user_ctx);
+void wifi_station_wps_timeout(void *data, void *user_ctx);
+
 struct wps_sm *gWpsSm = NULL;
 static wps_factory_information_t *s_factory_info = NULL;
 
@@ -119,11 +122,11 @@ void wps_task(void *pvParameters )
     wps_ioctl_param_t *param;
     bool del_task = false;
 
-    xSemaphoreGive(s_wps_task_create_sem);
+    os_semphr_give(s_wps_task_create_sem);
 
     wpa_printf(MSG_DEBUG, "wps_Task enter");
     for (;;) {
-        if ( pdPASS == xQueueReceive(s_wps_queue, &e, portMAX_DELAY) ) {
+        if ( TRUE == os_queue_recv(s_wps_queue, &e, OS_BLOCK) ) {
 
             if ( (e->sig >= SIG_WPS_ENABLE) && (e->sig < SIG_WPS_NUM) ) {
                 DATA_MUTEX_TAKE();
@@ -144,7 +147,7 @@ void wps_task(void *pvParameters )
                 param = (wps_ioctl_param_t *)e->par;
                 if (!param) {
                     wpa_printf(MSG_ERROR, "wpsT: invalid param sig=%d", e->sig);
-                    xSemaphoreGive(s_wps_api_sem);
+                    os_semphr_give(s_wps_api_sem);
                     break;
                 }
 
@@ -158,7 +161,7 @@ void wps_task(void *pvParameters )
                     param->ret = wifi_station_wps_start();
                 }
 
-                xSemaphoreGive(s_wps_api_sem);
+                os_semphr_give(s_wps_api_sem);
                 break;
 
             case SIG_WPS_RX: {
@@ -203,7 +206,7 @@ void wps_task(void *pvParameters )
             }
         }
     }
-    vTaskDelete(NULL);
+    os_task_delete(NULL);
 }
 
 /* wps_post() is thread-safe
@@ -232,7 +235,7 @@ int wps_post(uint32_t sig, uint32_t par)
         evt->par = par;
         DATA_MUTEX_GIVE();
 
-        if ( xQueueSend(s_wps_queue, &evt, 10 / portTICK_PERIOD_MS) != pdPASS) {
+        if (os_queue_send(s_wps_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
             wpa_printf(MSG_ERROR, "WPS: Q S E");
             DATA_MUTEX_TAKE();
             s_wps_sig_cnt[sig]--;
@@ -590,7 +593,7 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res)
         return ESP_FAIL;
     }
 
-    ets_timer_disarm(&sm->wps_msg_timeout_timer);
+    eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
 
     if (res) {
         *res = wps_enrollee_process_msg(sm->wps, expd->opcode, wps_buf);
@@ -679,7 +682,7 @@ int wps_tx_start(void)
     wps_sm_ether_send(sm, ETH_P_EAPOL, buf, len);
     wps_sm_free_eapol(buf);
 
-    ets_timer_arm(&sm->wps_eapol_start_timer, 3000, 0);
+    eloop_register_timeout(3, 0, wifi_station_wps_eapol_start_handle, NULL, NULL);
 
     return ESP_OK;
 }
@@ -697,8 +700,8 @@ int wps_start_pending(void)
 static void wps_stop_connection_timers(struct wps_sm *sm)
 {
     esp_wifi_disarm_sta_connection_timer_internal();
-    ets_timer_disarm(&sm->wps_msg_timeout_timer);
-    ets_timer_disarm(&sm->wps_success_cb_timer);
+    eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
 }
 
 static int wps_sm_init(struct wps_sm *sm)
@@ -735,7 +738,7 @@ int wps_stop_process(wifi_event_sta_wps_fail_reason_t reason_code)
 
     wpa_printf(MSG_DEBUG, "Write wps_fail_information");
 
-    esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), portMAX_DELAY);
+    esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), OS_BLOCK);
 
     return ESP_OK;
 }
@@ -769,8 +772,8 @@ int wps_finish(void)
 
             os_free(config);
         }
-        ets_timer_disarm(&sm->wps_success_cb_timer);
-        ets_timer_arm(&sm->wps_success_cb_timer, 1000, 0);
+        eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
+	eloop_register_timeout(1, 0, wifi_station_wps_success, NULL, NULL);
 
         ret = 0;
     } else {
@@ -824,14 +827,14 @@ int wps_start_msg_timer(void)
     if (sm->wps->state == WPS_FINISHED) {
         msg_timeout = 100;
         wpa_printf(MSG_DEBUG, "start msg timer WPS_FINISHED %d ms", msg_timeout);
-        ets_timer_disarm(&sm->wps_msg_timeout_timer);
-        ets_timer_arm(&sm->wps_msg_timeout_timer, msg_timeout, 0);
+	eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+	eloop_register_timeout(0, msg_timeout*1000, wifi_station_wps_msg_timeout, NULL, NULL);
         ret = 0;
     } else if (sm->wps->state == RECV_M2) {
-        msg_timeout = 5000;
+        msg_timeout = 5;
         wpa_printf(MSG_DEBUG, "start msg timer RECV_M2 %d ms", msg_timeout);
-        ets_timer_disarm(&sm->wps_msg_timeout_timer);
-        ets_timer_arm(&sm->wps_msg_timeout_timer, msg_timeout, 0);
+	eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+	eloop_register_timeout(msg_timeout, 0, wifi_station_wps_msg_timeout, NULL, NULL);
         ret = 0;
     }
     return ret;
@@ -984,10 +987,10 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
         case EAP_TYPE_IDENTITY:
             wpa_printf(MSG_DEBUG, "=========identity===========");
             sm->current_identifier = ehdr->identifier;
-            ets_timer_disarm(&sm->wps_eapol_start_timer);
+            eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
             wpa_printf(MSG_DEBUG,  "WPS: Build EAP Identity.");
             ret = wps_send_eap_identity_rsp(ehdr->identifier);
-            ets_timer_arm(&sm->wps_eapol_start_timer, 3000, 0);
+            eloop_register_timeout(3, 0, wifi_station_wps_eapol_start_handle, NULL, NULL);
             break;
         case EAP_TYPE_EXPANDED:
             wpa_printf(MSG_DEBUG, "=========expanded plen[%d], %d===========", plen, sizeof(*ehdr));
@@ -1023,15 +1026,15 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
     }
 out:
     if (ret != 0 && sm->ignore_sel_reg) {
-        wifi_wps_scan();
+        wifi_wps_scan(NULL, NULL);
     } else if ((ret != 0 || res == WPS_FAILURE)) {
         wifi_event_sta_wps_fail_reason_t reason_code = WPS_FAIL_REASON_NORMAL;
         wpa_printf(MSG_DEBUG, "wpa rx eapol internal: fail ret=%d", ret);
         wps_set_status(WPS_STATUS_DISABLE);
         esp_wifi_disarm_sta_connection_timer_internal();
-        ets_timer_disarm(&sm->wps_timeout_timer);
+        eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
 
-        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), portMAX_DELAY);
+        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), OS_BLOCK);
 
         return ret;
     }
@@ -1214,10 +1217,10 @@ wifi_station_wps_timeout_internal(void)
 
     wps_set_status(WPS_STATUS_DISABLE);
 
-    esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_TIMEOUT, 0, 0, portMAX_DELAY);
+    esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_TIMEOUT, 0, 0, OS_BLOCK);
 }
 
-void wifi_station_wps_timeout(void)
+void wifi_station_wps_timeout(void *data, void *user_ctx)
 {
 #ifdef USE_WPS_TASK
     wps_post(SIG_WPS_TIMER_TIMEOUT, 0);
@@ -1252,11 +1255,11 @@ wifi_station_wps_msg_timeout_internal(void)
         os_bzero(sm->ssid_len, sizeof(sm->ssid_len));
         os_bzero(sm->bssid, ETH_ALEN);
         sm->discover_ssid_cnt = 0;
-        wifi_wps_scan();
+        wifi_wps_scan(NULL, NULL);
     }
 }
 
-void wifi_station_wps_msg_timeout(void)
+void wifi_station_wps_msg_timeout(void *data, void *user_ctx)
 {
 #ifdef USE_WPS_TASK
     wps_post(SIG_WPS_TIMER_MSG_TIMEOUT, 0);
@@ -1283,14 +1286,14 @@ void wifi_station_wps_success_internal(void)
             os_memcpy(evt.ap_cred[i].passphrase, sm->key[i], sm->key_len[i]);
         }
         esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_SUCCESS, &evt,
-                                sizeof(evt), portMAX_DELAY);
+                                sizeof(evt), OS_BLOCK);
     } else {
         esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_SUCCESS,
-                                0, 0, portMAX_DELAY);
+                                0, 0, OS_BLOCK);
     }
 }
 
-void wifi_station_wps_success(void)
+void wifi_station_wps_success(void *data, void *user_ctx)
 {
 #ifdef USE_WPS_TASK
     wps_post(SIG_WPS_TIMER_SUCCESS_CB, 0);
@@ -1306,7 +1309,7 @@ void wifi_station_wps_eapol_start_handle_internal(void)
     wps_tx_start();
 }
 
-void wifi_station_wps_eapol_start_handle(void)
+void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx)
 {
 #ifdef USE_WPS_TASK
     wps_post(SIG_WPS_TIMER_EAPOL_START, 0);
@@ -1408,7 +1411,7 @@ wifi_station_wps_init(void)
     if (wps_get_type() == WPS_TYPE_PIN) {
         wifi_event_sta_wps_er_pin_t evt;
         os_memcpy(evt.pin_code, sm->wps->dev_password, 8);
-        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PIN, &evt, sizeof(evt), portMAX_DELAY);
+        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PIN, &evt, sizeof(evt), OS_BLOCK);
     }
 
     sm->wps->wps->cred_cb = save_credentials_cb;
@@ -1422,16 +1425,11 @@ wifi_station_wps_init(void)
         wps_build_ic_appie_wps_ar();
     }
 
-    ets_timer_disarm(&sm->wps_timeout_timer);
-    ets_timer_setfn(&sm->wps_timeout_timer, (ETSTimerFunc *)wifi_station_wps_timeout, NULL);
-    ets_timer_disarm(&sm->wps_msg_timeout_timer);
-    ets_timer_setfn(&sm->wps_msg_timeout_timer, (ETSTimerFunc *)wifi_station_wps_msg_timeout, NULL);
-    ets_timer_disarm(&sm->wps_success_cb_timer);
-    ets_timer_setfn(&sm->wps_success_cb_timer, (ETSTimerFunc *)wifi_station_wps_success, NULL);
-    ets_timer_disarm(&sm->wps_scan_timer);
-    ets_timer_setfn(&sm->wps_scan_timer, (ETSTimerFunc *)wifi_wps_scan, NULL);
-    ets_timer_disarm(&sm->wps_eapol_start_timer);
-    ets_timer_setfn(&sm->wps_eapol_start_timer, (ETSTimerFunc *)wifi_station_wps_eapol_start_handle, NULL);
+    eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
+    eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
 
     wps_cb = os_malloc(sizeof(struct wps_funcs));
     if (wps_cb == NULL) {
@@ -1476,16 +1474,11 @@ int wps_delete_timer(void)
         return ESP_OK;
     }
 
-    ets_timer_disarm(&sm->wps_success_cb_timer);
-    ets_timer_disarm(&sm->wps_timeout_timer);
-    ets_timer_disarm(&sm->wps_msg_timeout_timer);
-    ets_timer_disarm(&sm->wps_scan_timer);
-    ets_timer_disarm(&sm->wps_eapol_start_timer);
-    ets_timer_done(&sm->wps_success_cb_timer);
-    ets_timer_done(&sm->wps_timeout_timer);
-    ets_timer_done(&sm->wps_msg_timeout_timer);
-    ets_timer_done(&sm->wps_scan_timer);
-    ets_timer_done(&sm->wps_eapol_start_timer);
+    eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+    eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
+    eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
     esp_wifi_disarm_sta_connection_timer_internal();
     return ESP_OK;
 }
@@ -1549,7 +1542,7 @@ wifi_wps_scan_done(void *arg, STATUS status)
     } else {
         wpa_printf(MSG_INFO, "PBC session overlap!");
         wps_set_status(WPS_STATUS_DISABLE);
-        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, 0, 0, portMAX_DELAY);
+        esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, 0, 0, OS_BLOCK);
     }
 
     wpa_printf(MSG_DEBUG, "wps scan_done discover_ssid_cnt = %d", sm->discover_ssid_cnt);
@@ -1568,14 +1561,15 @@ wifi_wps_scan_done(void *arg, STATUS status)
 
         wpa_printf(MSG_DEBUG, "WPS: neg start");
         esp_wifi_connect();
-        ets_timer_disarm(&sm->wps_msg_timeout_timer);
-        ets_timer_arm(&sm->wps_msg_timeout_timer, 2000, 0);
+	eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
+	eloop_register_timeout(2, 0, wifi_station_wps_msg_timeout, NULL, NULL);
     } else if (wps_get_status() == WPS_STATUS_SCANNING) {
         if (wps_get_type() == WPS_TYPE_PIN && sm->scan_cnt > WPS_IGNORE_SEL_REG_MAX_CNT) {
             wpa_printf(MSG_INFO, "WPS: ignore selected registrar after %d scans", sm->scan_cnt);
             sm->ignore_sel_reg = true;
         }
-        ets_timer_arm(&sm->wps_scan_timer, 100, 0);
+        eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
+	eloop_register_timeout(0, 100*1000, wifi_wps_scan, NULL, NULL);
     } else {
         return;
     }
@@ -1594,7 +1588,7 @@ wifi_wps_scan_internal(void)
     esp_wifi_promiscuous_scan_start(NULL, wifi_wps_scan_done);
 }
 
-void wifi_wps_scan(void)
+void wifi_wps_scan(void *data, void *user_ctx)
 {
 #ifdef USE_WPS_TASK
     wps_post(SIG_WPS_TIMER_SCAN, 0);
@@ -1618,7 +1612,7 @@ int wifi_station_wps_start(void)
         return ESP_FAIL;
     }
 
-    ets_timer_arm(&sm->wps_timeout_timer, 120000, 0); /* 120s total */
+    eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
 
     switch (wps_get_status()) {
     case WPS_STATUS_DISABLE: {
@@ -1631,13 +1625,13 @@ int wifi_station_wps_start(void)
         sm->wps->wps->rf_band_cb = wps_rf_band_cb;
         wpabuf_clear_free(sm->wps->dh_privkey);
         sm->wps->dh_privkey = NULL;
-        wifi_wps_scan();
+        wifi_wps_scan(NULL, NULL);
         break;
     }
     case WPS_STATUS_SCANNING:
         sm->scan_cnt = 0;
-        ets_timer_disarm(&sm->wps_timeout_timer);
-        ets_timer_arm(&sm->wps_timeout_timer, 120000, 0); /* 120s total */
+        eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
+        eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
         break;
     default:
         break;
@@ -1653,19 +1647,19 @@ int wps_task_deinit(void)
     wpa_printf(MSG_DEBUG, "wps task deinit");
 
     if (s_wps_api_sem) {
-        vSemaphoreDelete(s_wps_api_sem);
+        os_semphr_delete(s_wps_api_sem);
         s_wps_api_sem = NULL;
         wpa_printf(MSG_DEBUG, "wps task deinit: free api sem");
     }
 
     if (s_wps_task_create_sem) {
-        vSemaphoreDelete(s_wps_task_create_sem);
+        os_semphr_delete(s_wps_task_create_sem);
         s_wps_task_create_sem = NULL;
         wpa_printf(MSG_DEBUG, "wps task deinit: free task create sem");
     }
 
     if (s_wps_queue) {
-        vQueueDelete(s_wps_queue);
+        os_queue_delete(s_wps_queue);
         s_wps_queue = NULL;
         wpa_printf(MSG_DEBUG, "wps task deinit: free queue");
     }
@@ -1675,7 +1669,7 @@ int wps_task_deinit(void)
     }
 
     if (s_wps_data_lock) {
-        vSemaphoreDelete(s_wps_data_lock);
+        os_semphr_delete(s_wps_data_lock);
         s_wps_data_lock = NULL;
         wpa_printf(MSG_DEBUG, "wps task deinit: free data lock");
     }
@@ -1691,26 +1685,26 @@ int wps_task_init(void)
      */
     wps_task_deinit();
 
-    s_wps_data_lock = xSemaphoreCreateRecursiveMutex();
+    s_wps_data_lock = os_recursive_mutex_create();
     if (!s_wps_data_lock) {
         wpa_printf(MSG_ERROR, "wps task init: failed to alloc data lock");
         goto _wps_no_mem;
     }
 
-    s_wps_api_sem = xSemaphoreCreateCounting(1, 0);
+    s_wps_api_sem = os_semphr_create(1, 0);
     if (!s_wps_api_sem) {
         wpa_printf(MSG_ERROR, "wps task init: failed to create api sem");
         goto _wps_no_mem;
     }
 
-    s_wps_task_create_sem = xSemaphoreCreateCounting(1, 0);
+    s_wps_task_create_sem = os_semphr_create(1, 0);
     if (!s_wps_task_create_sem) {
         wpa_printf(MSG_ERROR, "wps task init: failed to create task sem");
         goto _wps_no_mem;
     }
 
     os_bzero(s_wps_sig_cnt, SIG_WPS_NUM);
-    s_wps_queue = xQueueCreate(SIG_WPS_NUM, sizeof(s_wps_queue));
+    s_wps_queue = os_queue_create(SIG_WPS_NUM, sizeof(s_wps_queue));
     if (!s_wps_queue) {
         wpa_printf(MSG_ERROR, "wps task init: failed to alloc queue");
         goto _wps_no_mem;
@@ -1718,14 +1712,14 @@ int wps_task_init(void)
 
     wps_rxq_init();
 
-    ret = xTaskCreate(wps_task, "wpsT", WPS_TASK_STACK_SIZE, NULL, 2, &s_wps_task_hdl);
-    if (pdPASS != ret) {
+    ret = os_task_create(wps_task, "wpsT", WPS_TASK_STACK_SIZE, NULL, 2, &s_wps_task_hdl);
+    if (TRUE != ret) {
         wpa_printf(MSG_ERROR, "wps enable: failed to create task");
         goto _wps_no_mem;
     }
 
-    xSemaphoreTake(s_wps_task_create_sem, portMAX_DELAY);
-    vSemaphoreDelete(s_wps_task_create_sem);
+    os_semphr_take(s_wps_task_create_sem, OS_BLOCK);
+    os_semphr_delete(s_wps_task_create_sem);
     s_wps_task_create_sem = NULL;
 
     wpa_printf(MSG_DEBUG, "wifi wps enable: task prio:%d, stack:%d", 2, WPS_TASK_STACK_SIZE);
@@ -1747,7 +1741,7 @@ int wps_post_block(uint32_t sig, void *arg)
         return ESP_FAIL;
     }
 
-    if (pdPASS == xSemaphoreTake(s_wps_api_sem, portMAX_DELAY)) {
+    if (TRUE == os_semphr_take(s_wps_api_sem, OS_BLOCK)) {
         return param.ret;
     } else {
         return ESP_FAIL;

+ 6 - 10
components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h

@@ -61,11 +61,6 @@ struct wps_sm {
     u8 ap_cred_cnt;
     struct wps_device_data *dev;
     u8 uuid[16];
-    ETSTimer wps_timeout_timer;
-    ETSTimer wps_msg_timeout_timer;
-    ETSTimer wps_scan_timer;
-    ETSTimer wps_success_cb_timer;
-    ETSTimer wps_eapol_start_timer;
     u8 current_identifier;
     bool is_wps_scan;
     u8 channel;
@@ -81,18 +76,18 @@ struct wps_sm {
 
 #define API_MUTEX_TAKE() do {\
     if (!s_wps_api_lock) {\
-        s_wps_api_lock = xSemaphoreCreateRecursiveMutex();\
+        s_wps_api_lock = os_recursive_mutex_create();\
         if (!s_wps_api_lock) {\
             wpa_printf(MSG_ERROR, "wps api lock create failed");\
             return ESP_ERR_NO_MEM;\
         }\
     }\
-    xSemaphoreTakeRecursive(s_wps_api_lock, portMAX_DELAY);\
+    os_mutex_lock(s_wps_api_lock);\
 } while(0)
 
-#define API_MUTEX_GIVE() xSemaphoreGiveRecursive(s_wps_api_lock)
-#define DATA_MUTEX_TAKE() xSemaphoreTakeRecursive(s_wps_data_lock, portMAX_DELAY)
-#define DATA_MUTEX_GIVE() xSemaphoreGiveRecursive(s_wps_data_lock)
+#define API_MUTEX_GIVE() os_mutex_unlock(s_wps_api_lock)
+#define DATA_MUTEX_TAKE() os_mutex_lock(s_wps_data_lock)
+#define DATA_MUTEX_GIVE() os_mutex_unlock(s_wps_data_lock)
 
 struct wps_sm *wps_sm_get(void);
 int wps_station_wps_unregister_cb(void);
@@ -123,3 +118,4 @@ static inline int wps_set_status(uint32_t status)
     return esp_wifi_set_wps_status_internal(status);
 }
 int wps_init_cfg_pin(struct wps_config *cfg);
+void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);

+ 11 - 12
components/wpa_supplicant/port/eloop.c

@@ -16,7 +16,6 @@
 #include "common.h"
 #include "list.h"
 #include "eloop.h"
-#include "esp_wifi.h"
 
 struct eloop_timeout {
 	struct dl_list list;
@@ -32,8 +31,8 @@ struct eloop_data {
 	bool eloop_started;
 };
 
-#define ELOOP_LOCK() xSemaphoreTakeRecursive(eloop_data_lock, portMAX_DELAY)
-#define ELOOP_UNLOCK() xSemaphoreGiveRecursive(eloop_data_lock)
+#define ELOOP_LOCK() os_mutex_lock(eloop_data_lock)
+#define ELOOP_UNLOCK() os_mutex_unlock(eloop_data_lock)
 
 static void *eloop_data_lock = NULL;
 
@@ -43,10 +42,10 @@ int eloop_init(void)
 {
 	os_memset(&eloop, 0, sizeof(eloop));
 	dl_list_init(&eloop.timeout);
-	ets_timer_disarm(&eloop.eloop_timer);
-	ets_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run, NULL);
+	os_timer_disarm(&eloop.eloop_timer);
+	os_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run, NULL);
 
-	eloop_data_lock = xSemaphoreCreateRecursiveMutex();
+	eloop_data_lock = os_recursive_mutex_create();
 
 	if (!eloop_data_lock) {
 		wpa_printf(MSG_ERROR, "failed to create eloop data loop");
@@ -100,8 +99,8 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
 	ELOOP_UNLOCK();
 
 run:
-	ets_timer_disarm(&eloop.eloop_timer);
-	ets_timer_arm(&eloop.eloop_timer, 0, 0);
+	os_timer_disarm(&eloop.eloop_timer);
+	os_timer_arm(&eloop.eloop_timer, 0, 0);
 
 	return 0;
 
@@ -271,8 +270,8 @@ void eloop_run(void)
 				uint32_t ms;
 				os_reltime_sub(&timeout->time, &now, &tv);
 				ms = tv.sec * 1000 + tv.usec / 1000;
-				ets_timer_disarm(&eloop.eloop_timer);
-				ets_timer_arm(&eloop.eloop_timer, ms, 0);
+				os_timer_disarm(&eloop.eloop_timer);
+				os_timer_arm(&eloop.eloop_timer, ms, 0);
 				goto out;
 			}
 		}
@@ -321,9 +320,9 @@ void eloop_destroy(void)
 		eloop_remove_timeout(timeout);
 	}
 	if (eloop_data_lock) {
-		vSemaphoreDelete(eloop_data_lock);
+		os_semphr_delete(eloop_data_lock);
 		eloop_data_lock = NULL;
 	}
-	ets_timer_disarm(&eloop.eloop_timer);
+	os_timer_disarm(&eloop.eloop_timer);
 	os_memset(&eloop, 0, sizeof(eloop));
 }

+ 47 - 0
components/wpa_supplicant/port/include/os.h

@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include "esp_err.h"
 #include "supplicant_opt.h"
+#include "esp_wifi.h"
 
 typedef time_t os_time_t;
 
@@ -341,4 +342,50 @@ static inline void forced_memzero(void *ptr, size_t len)
 	}
 }
 #endif
+
+extern const wifi_osi_funcs_t *wifi_funcs;
+#define OS_BLOCK OSI_FUNCS_TIME_BLOCKING
+
+#define os_mutex_lock(a) wifi_funcs->_mutex_lock((a))
+#define os_mutex_unlock(a) wifi_funcs->_mutex_unlock((a))
+#define os_recursive_mutex_create() wifi_funcs->_recursive_mutex_create()
+
+#define os_queue_create(a, b) wifi_funcs->_queue_create((a), (b))
+#define os_queue_delete(a) wifi_funcs->_queue_delete(a)
+#define os_queue_send(a, b, c) wifi_funcs->_queue_send((a), (b), (c))
+#define os_queue_recv(a, b, c) wifi_funcs->_queue_recv((a), (b), (c))
+
+#define os_task_create(a,b,c,d,e,f) wifi_funcs->_task_create((a), (b), (c), (d), (e), (f))
+#define os_task_delete(a) wifi_funcs->_task_delete((a))
+#define os_task_get_current_task() wifi_funcs->_task_get_current_task()
+
+#define os_semphr_create(a, b) wifi_funcs->_semphr_create((a), (b))
+#define os_semphr_delete(a) wifi_funcs->_semphr_delete((a))
+#define os_semphr_give(a) wifi_funcs->_semphr_give((a))
+#define os_semphr_take(a, b) wifi_funcs->_semphr_take((a), (b))
+
+#define os_task_ms_to_tick(a) wifi_funcs->_task_ms_to_tick((a))
+#define os_timer_get_time(void) wifi_funcs->_esp_timer_get_time(void)
+
+static inline void os_timer_setfn(void *ptimer, void *pfunction, void *parg)
+{
+       return wifi_funcs->_timer_setfn(ptimer, pfunction, parg);
+}
+static inline void os_timer_disarm(void *ptimer)
+{
+       return wifi_funcs->_timer_disarm(ptimer);
+}
+static inline void os_timer_arm_us(void *ptimer,uint32_t u_seconds,bool repeat_flag)
+{
+       return wifi_funcs->_timer_arm_us(ptimer, u_seconds, repeat_flag);
+}
+static inline void os_timer_arm(void *ptimer,uint32_t milliseconds,bool repeat_flag)
+{
+       return wifi_funcs->_timer_arm(ptimer, milliseconds, repeat_flag);
+}
+static inline void os_timer_done(void *ptimer)
+{
+       return wifi_funcs->_timer_done(ptimer);
+}
+
 #endif /* OS_H */

+ 7 - 9
components/wpa_supplicant/src/ap/wpa_auth.c

@@ -55,6 +55,7 @@ static const u32 dot11RSNAConfigPairwiseUpdateCount = 4;
 #define WPA_SM_MAX_INDEX 16
 static void *s_sm_table[WPA_SM_MAX_INDEX];
 static u32 s_sm_valid_bitmap = 0;
+void resend_eapol_handle(void *data, void *user_ctx);
 
 static struct wpa_state_machine * wpa_auth_get_sm(u32 index)
 {
@@ -449,8 +450,7 @@ void wpa_auth_sta_deinit(struct wpa_state_machine *sm)
     if (sm == NULL)
         return;
 
-    ets_timer_disarm(&sm->resend_eapol);
-    ets_timer_done(&sm->resend_eapol);
+    eloop_cancel_timeout(resend_eapol_handle, (void*)(sm->index), NULL);
 
     if (sm->in_step_loop) {
         /* Must not free state machine while wpa_sm_step() is running.
@@ -806,8 +806,6 @@ continue_processing:
         }
         sm->MICVerified = TRUE;
         eloop_cancel_timeout(wpa_send_eapol_timeout, wpa_auth, sm);
-        ets_timer_disarm(&sm->resend_eapol);
-        ets_timer_done(&sm->resend_eapol);
         sm->pending_1_of_4_timeout = 0;
     }
 
@@ -1098,12 +1096,12 @@ int hostap_eapol_resend_process(void *timeout_ctx)
     return ESP_OK;
 }
 
-void resend_eapol_handle(void *timeout_ctx)
+void resend_eapol_handle(void *data, void *user_ctx)
 {
     wifi_ipc_config_t cfg;
 
     cfg.fn = hostap_eapol_resend_process;
-    cfg.arg = timeout_ctx;
+    cfg.arg = data;
     cfg.arg_size = 0;
     esp_wifi_ipc_internal(&cfg, false);
 }
@@ -1126,9 +1124,9 @@ static void wpa_send_eapol(struct wpa_authenticator *wpa_auth,
     ctr = pairwise ? sm->TimeoutCtr : sm->GTimeoutCtr;
     if (pairwise && ctr == 1 && !(key_info & WPA_KEY_INFO_MIC))
         sm->pending_1_of_4_timeout = 1;
-    ets_timer_disarm(&sm->resend_eapol);
-    ets_timer_setfn(&sm->resend_eapol, (ETSTimerFunc *)resend_eapol_handle, (void*)(sm->index));
-    ets_timer_arm(&sm->resend_eapol, 1000, 0);
+
+    eloop_cancel_timeout(resend_eapol_handle, (void*)(sm->index), NULL);
+    eloop_register_timeout(1, 0, resend_eapol_handle, (void*)(sm->index), NULL);
 }
 
 static int wpa_verify_key_mic(int akmp, struct wpa_ptk *PTK, u8 *data,

+ 0 - 1
components/wpa_supplicant/src/ap/wpa_auth_i.h

@@ -130,7 +130,6 @@ struct wpa_state_machine {
 
 	int pending_1_of_4_timeout;
 	u32 index;
-	ETSTimer resend_eapol;
 	struct rsn_sppamsdu_sup spp_sup;
 };
 

+ 6 - 18
components/wpa_supplicant/src/common/mbo.c

@@ -13,6 +13,7 @@
 #include "utils/includes.h"
 
 #include "utils/common.h"
+#include "utils/eloop.h"
 #include "common/ieee802_11_defs.h"
 #include "rsn_supp/wpa.h"
 #include "wpa_supplicant_i.h"
@@ -21,7 +22,6 @@
 #include "ieee802_11_common.h"
 
 #ifdef ESP_SUPPLICANT
-#include "esp_timer.h"
 #include "esp_mbo.h"
 
 extern struct wpa_supplicant g_wpa_supp;
@@ -522,18 +522,16 @@ wpa_bss_tmp_disallowed * wpas_get_disallowed_bss(struct wpa_supplicant *wpa_s,
 	return NULL;
 }
 
-static void wpa_bss_tmp_disallow_timeout(void *timeout_ctx)
+static void wpa_bss_tmp_disallow_timeout(void *timeout_ctx, void *user_ctx)
 {
 	struct wpa_supplicant *wpa_s = &g_wpa_supp;
-	struct wpa_bss_tmp_disallowed *tmp, *bss = timeout_ctx;
+	struct wpa_bss_tmp_disallowed *tmp, *bss = user_ctx;
 
 	/* Make sure the bss is not already freed */
 	dl_list_for_each(tmp, &wpa_s->bss_tmp_disallowed,
 			 struct wpa_bss_tmp_disallowed, list) {
 		if (bss == tmp) {
 			dl_list_del(&tmp->list);
-			esp_timer_stop(bss->blacklist_timer);
-			esp_timer_delete(bss->blacklist_timer);
 			os_free(tmp);
 			break;
 		}
@@ -547,7 +545,7 @@ void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
 
 	bss = wpas_get_disallowed_bss(wpa_s, bssid);
 	if (bss) {
-		esp_timer_stop(bss->blacklist_timer);
+		eloop_cancel_timeout(wpa_bss_tmp_disallow_timeout, wpa_s, bss);
 		goto finish;
 	}
 
@@ -558,22 +556,12 @@ void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
 		return;
 	}
 
-	esp_timer_create_args_t blacklist_timer_create = {
-		.callback = &wpa_bss_tmp_disallow_timeout,
-		.arg = bss,
-		.dispatch_method = ESP_TIMER_TASK,
-		.name = "blacklist_timeout_timer"
-	};
-	if (esp_timer_create(&blacklist_timer_create, &(bss->blacklist_timer)) != ESP_OK) {
-		os_free(bss);
-		return;
-	}
-
 	os_memcpy(bss->bssid, bssid, ETH_ALEN);
 	dl_list_add(&wpa_s->bss_tmp_disallowed, &bss->list);
 
 finish:
-	esp_timer_start_once(bss->blacklist_timer, (sec + 1) * 1e6);
+	eloop_register_timeout(sec, 0, wpa_bss_tmp_disallow_timeout,
+			       wpa_s, bss);
 }
 
 int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s,

+ 0 - 3
components/wpa_supplicant/src/common/wpa_supplicant_i.h

@@ -12,7 +12,6 @@
 
 #include "drivers/driver.h"
 #include "common/ieee802_11_defs.h"
-#include "esp_timer.h"
 /*
  * struct rrm_data - Data used for managing RRM features
  */
@@ -47,8 +46,6 @@ struct wpa_bss_tmp_disallowed {
 	u8 bssid[ETH_ALEN];
 #ifndef ESP_SUPPLICANT
 	int rssi_threshold;
-#else
-	esp_timer_handle_t blacklist_timer;
 #endif
 };
 

+ 21 - 29
components/wpa_supplicant/src/rsn_supp/pmksa_cache.c

@@ -6,14 +6,14 @@
  * See README for more details.
  */
 
-#include "utils/includes.h"
-
+#include "includes.h"
+#include "common.h"
+#include "eloop.h"
 #include "rsn_supp/wpa.h"
 #include "rsn_supp/wpa_i.h"
 #include "common/eapol_common.h"
 #include "common/ieee802_11_defs.h"
 #include "pmksa_cache.h"
-#include "esp_timer.h"
 
 #ifdef IEEE8021X_EAPOL
 
@@ -25,7 +25,6 @@ struct rsn_pmksa_cache {
     struct rsn_pmksa_cache_entry *pmksa; /* PMKSA cache */
     int pmksa_count; /* number of entries in PMKSA cache */
     struct wpa_sm *sm; /* TODO: get rid of this reference(?) */
-    esp_timer_handle_t cache_timeout_timer;
 
     void (*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx,
             enum pmksa_free_reason reason);
@@ -52,12 +51,13 @@ static void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa,
 }
 
 
-static void pmksa_cache_expire(void *eloop_ctx)
+static void pmksa_cache_expire(void *eloop_ctx, void *user_data)
 {
     struct rsn_pmksa_cache *pmksa = eloop_ctx;
-    int64_t now_sec = esp_timer_get_time() / 1e6;
+    struct os_reltime now;
 
-    while (pmksa->pmksa && pmksa->pmksa->expiration <= now_sec) {
+    os_get_reltime(&now);
+    while (pmksa->pmksa && pmksa->pmksa->expiration <= now.sec) {
         struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
         pmksa->pmksa = entry->next;
         wpa_printf(MSG_DEBUG, "RSN: expired PMKSA cache entry for "
@@ -71,16 +71,18 @@ static void pmksa_cache_expire(void *eloop_ctx)
 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa)
 {
     int sec;
-    int64_t now_sec = esp_timer_get_time() / 1e6;
+    struct os_reltime now;
 
-    esp_timer_stop(pmksa->cache_timeout_timer);
+    eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
     if (pmksa->pmksa == NULL)
         return;
-    sec = pmksa->pmksa->expiration - now_sec;
+
+    os_get_reltime(&now);
+    sec = pmksa->pmksa->expiration - now.sec;
     if (sec < 0)
         sec = 0;
 
-    esp_timer_start_once(pmksa->cache_timeout_timer, (sec + 1) * 1e6);
+    eloop_register_timeout(sec + 1, 0, pmksa_cache_expire, pmksa, NULL);
 }
 
 /**
@@ -107,7 +109,7 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
         const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
 {
     struct rsn_pmksa_cache_entry *entry, *pos, *prev;
-    int64_t now_sec = esp_timer_get_time() / 1e6;
+    struct os_reltime now;
 
     if (pmk_len > PMK_LEN_MAX)
         return NULL;
@@ -129,8 +131,9 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
     else
         rsn_pmkid(pmk, pmk_len, aa, spa, entry->pmkid,
                   wpa_key_mgmt_sha256(akmp));
-    entry->expiration = now_sec + dot11RSNAConfigPMKLifetime;
-    entry->reauth_time = now_sec + dot11RSNAConfigPMKLifetime *
+    os_get_reltime(&now);
+    entry->expiration = now.sec + dot11RSNAConfigPMKLifetime;
+    entry->reauth_time = now.sec + dot11RSNAConfigPMKLifetime *
         dot11RSNAConfigPMKReauthThreshold / 100;
     entry->akmp = akmp;
     os_memcpy(entry->aa, aa, ETH_ALEN);
@@ -286,8 +289,7 @@ void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
         os_free(prev);
     }
     pmksa_cache_set_expiration(pmksa);
-    esp_timer_stop(pmksa->cache_timeout_timer);
-    esp_timer_delete(pmksa->cache_timeout_timer);
+    eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
     os_free(pmksa);
 }
 
@@ -459,7 +461,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
     int i, ret;
     char *pos = buf;
     struct rsn_pmksa_cache_entry *entry;
-    int64_t now_sec = esp_timer_get_time() / 1e6;
+    struct os_reltime now;
     ret = os_snprintf(pos, buf + len - pos,
             "Index / AA / PMKID / expiration (in seconds) / "
             "opportunistic\n");
@@ -468,6 +470,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
     pos += ret;
     i = 0;
     entry = pmksa->pmksa;
+    os_get_reltime(&now);
     while (entry) {
         i++;
         ret = os_snprintf(pos, buf + len - pos, "%d " MACSTR " ",
@@ -478,7 +481,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
         pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid,
                 PMKID_LEN);
         ret = os_snprintf(pos, buf + len - pos, " %d %d\n",
-                (int) (entry->expiration - now_sec),
+                (int) (entry->expiration - now.sec),
                 entry->opportunistic);
         if (os_snprintf_error(buf + len - pos, ret))
             return pos - buf;
@@ -510,17 +513,6 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
         pmksa->sm = sm;
         pmksa->pmksa_count = 0;
         pmksa->pmksa = NULL;
-
-        esp_timer_create_args_t pmksa_cache_timeout_timer_create = {
-            .callback = &pmksa_cache_expire,
-            .arg = pmksa,
-            .dispatch_method = ESP_TIMER_TASK,
-            .name = "pmksa_timeout_timer"
-        };
-        if (esp_timer_create(&pmksa_cache_timeout_timer_create, &(pmksa->cache_timeout_timer)) != ESP_OK) {
-            os_free(pmksa);
-            pmksa = NULL;
-        }
     }
 
     return pmksa;

+ 13 - 17
components/wpa_supplicant/src/rsn_supp/wpa.c

@@ -63,6 +63,7 @@ void wpa_set_passphrase(char * passphrase, u8 *ssid, size_t ssid_len);
 
 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
 static bool wpa_supplicant_gtk_in_use(struct wpa_sm *sm, struct wpa_gtk_data *gd);
+void wpa_supplicant_stop_countermeasures(void *data, void *user_ctx);
 static inline enum wpa_states   wpa_sm_get_state(struct wpa_sm *sm)
 {
     return sm->wpa_state;;
@@ -2098,9 +2099,9 @@ out:
  */
 void wpa_sm_set_state(enum wpa_states state)
 {
-       struct wpa_sm *sm = &gWpaSm;
+    struct wpa_sm *sm = &gWpaSm;
     if(WPA_MIC_FAILURE==WPA_SM_STATE(sm))
-        ets_timer_disarm(&(sm->cm_timer));
+    eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
     sm->wpa_state= state;
 }
 
@@ -2456,26 +2457,25 @@ void wpa_supplicant_clr_countermeasures(u16 *pisunicast)
 {
     struct wpa_sm *sm = &gWpaSm;
     sm->mic_errors_seen = 0;
-    ets_timer_done(&(sm->cm_timer));
     wpa_printf(MSG_DEBUG, "WPA: TKIP countermeasures clean\n");
 }
 
 /*recovery from countermeasures state, countermeasures state is period that stop connection with ap
   also used in wpa_init after connecting with ap
 */
-void wpa_supplicant_stop_countermeasures(u16 *pisunicast)
+void wpa_supplicant_stop_countermeasures(void *data, void *user_ctx)
 {
-       struct wpa_sm *sm = &gWpaSm;
+    struct wpa_sm *sm = &gWpaSm;
 
-       ets_timer_done(&(sm->cm_timer));
     if (sm->countermeasures) {
         sm->countermeasures = 0;
-              wpa_supplicant_clr_countermeasures(NULL);
+        wpa_supplicant_clr_countermeasures(NULL);
+        eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
 
         wpa_printf(MSG_DEBUG, "WPA: TKIP countermeasures stopped\n");
-              /*renew scan preocess, this isn't done now*/
+        /*renew scan preocess, this isn't done now*/
     }
-       wpa_sm_set_state(WPA_DISCONNECTED);
+    wpa_sm_set_state(WPA_DISCONNECTED);
 }
 
 int wpa_michael_mic_failure(u16 isunicast)
@@ -2504,10 +2504,8 @@ int wpa_michael_mic_failure(u16 isunicast)
         /*deauthenticate AP*/
 
         /*stop monitor next mic_failure timer,disconnect for 60sec, then stop contermeasures*/
-        ets_timer_disarm(&(sm->cm_timer));
-        ets_timer_done(&(sm->cm_timer));
-        ets_timer_setfn(&(sm->cm_timer), (ETSTimerFunc *)wpa_supplicant_stop_countermeasures, NULL);
-        ets_timer_arm(&(sm->cm_timer), 60*1000, false);
+        eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
+        eloop_register_timeout(60, 0, wpa_supplicant_stop_countermeasures, NULL, NULL);
 
         /* TODO: mark the AP rejected for 60 second. STA is
          * allowed to associate with another AP.. */
@@ -2516,10 +2514,8 @@ int wpa_michael_mic_failure(u16 isunicast)
         wpa_sm_set_state(WPA_MIC_FAILURE);
         wpa_sm_key_request(sm, 1, isunicast);
         /*start 60sec counter to monitor whether next mic_failure occur in this period, or clear mic_errors_seen*/
-        ets_timer_disarm(&(sm->cm_timer));
-        ets_timer_done(&(sm->cm_timer));
-        ets_timer_setfn(&(sm->cm_timer), (ETSTimerFunc *)wpa_supplicant_clr_countermeasures, NULL);
-        ets_timer_arm(&(sm->cm_timer), 60*1000, false);
+        eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
+        eloop_register_timeout(60, 0, wpa_supplicant_stop_countermeasures, NULL, NULL);
     }
 
     return 0;

+ 0 - 1
components/wpa_supplicant/src/rsn_supp/wpa_i.h

@@ -50,7 +50,6 @@ struct wpa_sm {
     int rsn_enabled; /* Whether RSN is enabled in configuration */
 
     int countermeasures; /*TKIP countermeasures state flag, 1:in countermeasures state*/
-    ETSTimer  cm_timer;
 
     u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
     size_t assoc_wpa_ie_len;

+ 3 - 3
components/wpa_supplicant/src/wps/wps_enrollee.c

@@ -9,6 +9,7 @@
 #include "includes.h"
 
 #include "common.h"
+#include "eloop.h"
 #include "crypto/crypto.h"
 #include "crypto/sha256.h"
 #include "crypto/random.h"
@@ -1364,12 +1365,11 @@ extern struct wps_sm *gWpsSm;
 static enum wps_process_res wps_process_wsc_start(struct wps_data *wps,
 						const struct wpabuf *msg)
 {
-	struct wps_sm *sm = gWpsSm;
 	enum wps_process_res ret = WPS_CONTINUE;
 
 	wpa_printf(MSG_DEBUG,  "WPS: Received WSC_START");
-	ets_timer_disarm(&sm->wps_eapol_start_timer);
-        wps->state = SEND_M1;
+	eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
+	wps->state = SEND_M1;
 	return ret;
 }
 

+ 6 - 1
components/wpa_supplicant/test/test_eloop.c

@@ -44,12 +44,17 @@ void callback(void *a, void *b)
 
 }
 
+extern const wifi_osi_funcs_t *wifi_funcs;
 /* Check if eloop runs its timers correctly & in correct order */
 TEST_CASE("Test eloop timers run", "[eloop]")
 {
 	int execution_order[6] = {1, 5, 3, 0, 2, 4};
 	int index[6] = {0,1,2,3,4,5};
 
+	wifi_funcs = WIFI_OSI_FUNCS_INITIALIZER();
+	if (!wifi_funcs) {
+		TEST_ASSERT(1);
+	}
 	eloop_init();
 	os_get_reltime(&ts);
 	for (int i = 0; i < 6; i++) {
@@ -59,7 +64,7 @@ TEST_CASE("Test eloop timers run", "[eloop]")
 
 	/* wait for all timers to run */
 	os_sleep(20, 0);
-
+	t = 0;
 	/* check the execution order, this will also check whether they were fired at correct time */
 	TEST_ASSERT(memcmp(execution_order, executed_order, 6*sizeof(int)) == 0);
 	eloop_destroy();

+ 0 - 1
tools/ci/check_copyright_ignore.txt

@@ -705,7 +705,6 @@ components/esp_timer/test/test_esp_timer_light_sleep.c
 components/esp_timer/test/test_ets_timer.c
 components/esp_wifi/include/esp_coexist_adapter.h
 components/esp_wifi/include/esp_mesh_internal.h
-components/esp_wifi/include/esp_private/esp_wifi_private.h
 components/esp_wifi/include/esp_private/esp_wifi_types_private.h
 components/esp_wifi/include/esp_private/wifi_types.h
 components/esp_wifi/include/esp_smartconfig.h