From 06eb41a7a1e7c1ed50336293c5ee22554fb1d081 Mon Sep 17 00:00:00 2001 From: Evlers <1425295900@qq.com> Date: Sun, 24 Mar 2024 12:39:36 +0800 Subject: [PATCH] [wlan][cmd] fixed a duplicate issue with the wifi scan command --- components/drivers/wlan/wlan_cmd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/drivers/wlan/wlan_cmd.c b/components/drivers/wlan/wlan_cmd.c index fe5910b242..b50261d42a 100644 --- a/components/drivers/wlan/wlan_cmd.c +++ b/components/drivers/wlan/wlan_cmd.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018-08-13 tyx the first version + * 2024-03-24 Evlers fixed a duplicate issue with the wifi scan command */ #include @@ -388,6 +389,7 @@ static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *pa struct rt_wlan_info *info = RT_NULL; int index = 0; int ret = RT_EOK; + rt_uint32_t last_num = scan_result.num; RT_ASSERT(event == RT_WLAN_EVT_SCAN_REPORT); RT_ASSERT(buff != RT_NULL); @@ -404,8 +406,12 @@ static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *pa scan_filter->ssid.len == info->ssid.len && rt_memcmp(&scan_filter->ssid.val[0], &info->ssid.val[0], scan_filter->ssid.len) == 0)) { - /*Print the info*/ - print_ap_info(info,index); + /*Check whether a new ap is added*/ + if (last_num < scan_result.num) + { + /*Print the info*/ + print_ap_info(info,index); + } index++; *((int *)(parameter)) = index;