未验证 提交 ce2313d2 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #1906 from enkiller/wlan-dev

[components][wlan] 修复某些情况下模式初始化两遍的bug
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册