mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-06 21:24:34 +08:00
[components][wlan] 修复某些情况下模式初始化两遍的bug
This commit is contained in:
parent
9c255e7d2f
commit
1e0e221dd7
@ -495,7 +495,7 @@ static void rt_wlan_event_dispatch(struct rt_wlan_device *device, rt_wlan_dev_ev
|
|||||||
{
|
{
|
||||||
user_buff = *buff;
|
user_buff = *buff;
|
||||||
}
|
}
|
||||||
/* 事件处理 */
|
/* Event Handle */
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
case RT_WLAN_DEV_EVT_CONNECT:
|
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);
|
RT_WLAN_LOG_E("not find device, set mode failed! name:%s", dev_name);
|
||||||
return -RT_EIO;
|
return -RT_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MGNT_LOCK();
|
||||||
if (RT_WLAN_DEVICE(device)->mode == mode)
|
if (RT_WLAN_DEVICE(device)->mode == mode)
|
||||||
{
|
{
|
||||||
RT_WLAN_LOG_D("L:%d this device mode is set");
|
RT_WLAN_LOG_D("L:%d this device mode is set");
|
||||||
|
MGNT_UNLOCK();
|
||||||
return RT_EOK;
|
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_DEVICE(device)->flags & RT_WLAN_FLAG_AP_ONLY))
|
||||||
{
|
{
|
||||||
RT_WLAN_LOG_I("this device ap mode only");
|
RT_WLAN_LOG_I("this device ap mode only");
|
||||||
|
MGNT_UNLOCK();
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
}
|
}
|
||||||
else if ((mode == RT_WLAN_AP) &&
|
else if ((mode == RT_WLAN_AP) &&
|
||||||
(RT_WLAN_DEVICE(device)->flags & RT_WLAN_FLAG_STA_ONLY))
|
(RT_WLAN_DEVICE(device)->flags & RT_WLAN_FLAG_STA_ONLY))
|
||||||
{
|
{
|
||||||
RT_WLAN_LOG_I("this device sta mode only");
|
RT_WLAN_LOG_I("this device sta mode only");
|
||||||
|
MGNT_UNLOCK();
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* device == sta and change to ap, should deinit
|
* device == sta and change to ap, should deinit
|
||||||
* device == ap and change to sta, should deinit
|
* device == ap and change to sta, should deinit
|
||||||
*/
|
*/
|
||||||
MGNT_LOCK();
|
|
||||||
if (((mode == RT_WLAN_STATION) && (RT_WLAN_DEVICE(device) == AP_DEVICE())) ||
|
if (((mode == RT_WLAN_STATION) && (RT_WLAN_DEVICE(device) == AP_DEVICE())) ||
|
||||||
((mode == RT_WLAN_AP) && (RT_WLAN_DEVICE(device) == STA_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;
|
return &scan_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run scna */
|
/* run scan */
|
||||||
err = rt_wlan_dev_scan(STA_DEVICE(), info);
|
err = rt_wlan_dev_scan(STA_DEVICE(), info);
|
||||||
if (err != RT_EOK)
|
if (err != RT_EOK)
|
||||||
{
|
{
|
||||||
rt_wlan_complete_delete(complete);
|
rt_wlan_complete_delete(complete);
|
||||||
RT_WLAN_LOG_E("scna sync fail");
|
RT_WLAN_LOG_E("scan sync fail");
|
||||||
MGNT_UNLOCK();
|
MGNT_UNLOCK();
|
||||||
return RT_NULL;
|
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;
|
set = 0x1 << RT_WLAN_DEV_EVT_SCAN_DONE;
|
||||||
if (!(recved & set))
|
if (!(recved & set))
|
||||||
{
|
{
|
||||||
RT_WLAN_LOG_E("scna wait timeout!");
|
RT_WLAN_LOG_E("scan wait timeout!");
|
||||||
MGNT_UNLOCK();
|
MGNT_UNLOCK();
|
||||||
return &scan_result;
|
return &scan_result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user