@@ -144,7 +144,9 @@ static esp_err_t wifi_join(const char *ssid, const char *password)
144144 return ESP_ERR_INVALID_ARG ;
145145 }
146146
147+ esp_openthread_task_switching_lock_release ();
147148 esp_err_t err = example_wifi_sta_do_connect (wifi_config , true);
149+ esp_openthread_task_switching_lock_acquire (portMAX_DELAY );
148150 return err ;
149151}
150152
@@ -177,7 +179,9 @@ void esp_ot_wifi_border_router_init_flag_set(bool initialized)
177179esp_err_t esp_ot_wifi_connect (const char * ssid , const char * password )
178180{
179181 if (!s_wifi_initialized ) {
182+ esp_openthread_task_switching_lock_release ();
180183 example_wifi_start ();
184+ esp_openthread_task_switching_lock_acquire (portMAX_DELAY );
181185#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_OPENTHREAD_RADIO_NATIVE
182186 ESP_ERROR_CHECK (esp_coex_wifi_i154_enable ());
183187#endif
@@ -220,7 +224,9 @@ esp_err_t esp_ot_wifi_disconnect(void)
220224 ESP_ERROR_CHECK (esp_event_handler_unregister (WIFI_EVENT , WIFI_EVENT_STA_CONNECTED , & handler_on_wifi_connect ));
221225 s_wifi_handler_registered = false;
222226 s_wifi_state = OT_WIFI_DISCONNECTED ;
227+ esp_openthread_task_switching_lock_release ();
223228 esp_err_t err = example_wifi_sta_do_disconnect ();
229+ esp_openthread_task_switching_lock_acquire (portMAX_DELAY );
224230 return err ;
225231}
226232
@@ -294,12 +300,10 @@ otError esp_ot_process_wifi_cmd(void *aContext, uint8_t aArgsLength, char *aArgs
294300 }
295301 if (esp_ot_wifi_connect (ssid , psk ) == ESP_OK ) {
296302 if (!s_border_router_initialized ) {
297- esp_openthread_lock_acquire (portMAX_DELAY );
298303 esp_openthread_set_backbone_netif (get_example_netif ());
299304 if (esp_openthread_border_router_init () != ESP_OK ) {
300305 ESP_LOGE (OT_EXT_CLI_TAG , "Fail to initialize border router" );
301306 }
302- esp_openthread_lock_release ();
303307 s_border_router_initialized = true;
304308 }
305309 otCliOutputFormat ("wifi sta is connected successfully\n" );
0 commit comments