diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index c8f190239cf8a953af583626fdec7471bed2f764..1d0b0c4aa7f15f866c1c193ce6f036bb810b9a88 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -495,7 +495,7 @@ static void rt_wlan_event_dispatch(struct rt_wlan_device *device, rt_wlan_dev_ev { user_buff = *buff; } - /* 事件处理 */ + /* Event Handle */ switch (event) { case RT_WLAN_DEV_EVT_CONNECT: @@ -737,9 +737,12 @@ rt_err_t rt_wlan_set_mode(const char *dev_name, rt_wlan_mode_t mode) RT_WLAN_LOG_E("not find device, set mode failed! name:%s", dev_name); return -RT_EIO; } + + MGNT_LOCK(); if (RT_WLAN_DEVICE(device)->mode == mode) { RT_WLAN_LOG_D("L:%d this device mode is set"); + MGNT_UNLOCK(); return RT_EOK; } @@ -747,19 +750,21 @@ rt_err_t rt_wlan_set_mode(const char *dev_name, rt_wlan_mode_t mode) (RT_WLAN_DEVICE(device)->flags & RT_WLAN_FLAG_AP_ONLY)) { RT_WLAN_LOG_I("this device ap mode only"); + MGNT_UNLOCK(); return -RT_ERROR; } else if ((mode == RT_WLAN_AP) && (RT_WLAN_DEVICE(device)->flags & RT_WLAN_FLAG_STA_ONLY)) { RT_WLAN_LOG_I("this device sta mode only"); + MGNT_UNLOCK(); return -RT_ERROR; } + /* * device == sta and change to ap, should deinit * device == ap and change to sta, should deinit */ - MGNT_LOCK(); if (((mode == RT_WLAN_STATION) && (RT_WLAN_DEVICE(device) == AP_DEVICE())) || ((mode == RT_WLAN_AP) && (RT_WLAN_DEVICE(device) == STA_DEVICE()))) { @@ -1627,12 +1632,12 @@ struct rt_wlan_scan_result *rt_wlan_scan_with_info(struct rt_wlan_info *info) return &scan_result; } - /* run scna */ + /* run scan */ err = rt_wlan_dev_scan(STA_DEVICE(), info); if (err != RT_EOK) { rt_wlan_complete_delete(complete); - RT_WLAN_LOG_E("scna sync fail"); + RT_WLAN_LOG_E("scan sync fail"); MGNT_UNLOCK(); return RT_NULL; } @@ -1646,7 +1651,7 @@ struct rt_wlan_scan_result *rt_wlan_scan_with_info(struct rt_wlan_info *info) set = 0x1 << RT_WLAN_DEV_EVT_SCAN_DONE; if (!(recved & set)) { - RT_WLAN_LOG_E("scna wait timeout!"); + RT_WLAN_LOG_E("scan wait timeout!"); MGNT_UNLOCK(); return &scan_result; }