diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 56e5b8373ac540ab66248c42be5008dd6bddaadf..4aceee3b4ed05ebff58503336cf14cab0e8fa7e5 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 e0f9eff2790b0345b925691a099ceaa9502cfc05..2490c2c4566502fe903736629252536f62e27ac2 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 5dc0119abd55b1503c8c3d7c0d3468c2bd919356..88923a61e6aab44645c81d73a46b8b0b7f7971fe 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 57d8dd9d78dadddffa750cfcf19d3e48af987ae7..df0827bb7b09746591a8acc479adb36814fd21dd 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)