From 6fbc7494b830a5d6e39f53a1ab3baebdbde64505 Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Thu, 25 Jul 2019 10:30:54 +0800 Subject: [PATCH] =?UTF-8?q?[components][drivers][wlan]=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BF=9E=E6=8E=A5=E5=91=A8=E6=9C=9F=E5=8F=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=8F=AF=E6=8C=87=E5=AE=9A=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/Kconfig | 6 ++++++ components/drivers/wlan/wlan_dev.c | 12 ++++++++++-- components/drivers/wlan/wlan_mgnt.c | 6 +----- components/drivers/wlan/wlan_mgnt.h | 4 ++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 56e5b8373a..4aceee3b4e 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -471,6 +471,12 @@ menuconfig RT_USING_WIFI select RT_WLAN_CFG_ENABLE select RT_WLAN_WORK_THREAD_ENABLE default y + + if RT_WLAN_AUTO_CONNECT_ENABLE + config AUTO_CONNECTION_PERIOD_MS + int "Auto connect period(ms)" + default 2000 + endif endif config RT_WLAN_CFG_ENABLE diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index e0f9eff279..2490c2c456 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -535,8 +535,16 @@ rt_err_t rt_wlan_dev_scan(struct rt_wlan_device *device, struct rt_wlan_info *in } rt_memcpy(&scan_info.ssid, &info->ssid, sizeof(rt_wlan_ssid_t)); rt_memcpy(scan_info.bssid, info->bssid, RT_WLAN_BSSID_MAX_LENGTH); - scan_info.channel_min = -1; - scan_info.channel_max = -1; + if (info->channel > 0) + { + scan_info.channel_min = info->channel; + scan_info.channel_max = info->channel; + } + else + { + scan_info.channel_min = -1; + scan_info.channel_max = -1; + } p_scan_info = &scan_info; } result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_SCAN, p_scan_info); diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index 5dc0119abd..88923a61e6 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -58,10 +58,6 @@ #define TIME_START() #endif -#ifndef DISCONNECT_RESPONSE_MS -#define DISCONNECT_RESPONSE_MS (2000) -#endif - #if RT_WLAN_EBOX_NUM < 1 #error "event box num Too few" #endif @@ -2020,7 +2016,7 @@ int rt_wlan_init(void) rt_mutex_init(&complete_mutex, "complete", RT_IPC_FLAG_FIFO); #ifdef RT_WLAN_AUTO_CONNECT_ENABLE rt_timer_init(&reconnect_time, "wifi_tim", rt_wlan_cyclic_check, RT_NULL, - rt_tick_from_millisecond(DISCONNECT_RESPONSE_MS), + rt_tick_from_millisecond(AUTO_CONNECTION_PERIOD_MS), RT_TIMER_FLAG_PERIODIC | RT_TIMER_FLAG_SOFT_TIMER); #endif _init_flag = 1; diff --git a/components/drivers/wlan/wlan_mgnt.h b/components/drivers/wlan/wlan_mgnt.h index 57d8dd9d78..df0827bb7b 100644 --- a/components/drivers/wlan/wlan_mgnt.h +++ b/components/drivers/wlan/wlan_mgnt.h @@ -41,6 +41,10 @@ extern "C" { #define RT_WLAN_SCAN_RETRY_CNT (3) #endif +#ifndef AUTO_CONNECTION_PERIOD_MS +#define AUTO_CONNECTION_PERIOD_MS (2000) +#endif + /*state fot station*/ #define RT_WLAN_STATE_CONNECT (1UL << 0) #define RT_WLAN_STATE_CONNECTING (1UL << 1) -- GitLab