_WLAN_BSS_LIST is updated very slow if a Hotspot is turned off

Symbol Tabios 1 Reputation point
2022-10-10T05:37:46.987+00:00

I'm currently developing a windows application which detects WiFi network changes every 10 to 15 seconds. There is no problem with detecting new mobile hotspots (updates were reflected after at least 20 or 30 seconds). However, there is a problem when a mobile hotspot is turned off as it disappears in the _WLAN_BSS_LIST after at least 90 to 120 seconds.

I used WlanScan and WlanGetAvailableNetworkList to retrieve the updated list of WiFi networks. I even used WlanRegisterNotification to notify changes thru callback. However, same behavior exists. It seems that the cache list of WiFi networks has issues when a mobile hotspot is turned off.

I also tried checking the following but behavior is still the same.

https://stackoverflow.com/questions/52243831/refresh-wifi-network-list-with-wlanscan-convert-api-syntax-from-c-sharp-to-vb

I'm using Kotlin multiplatform to develop the application.

I'm also using the following:

248779-image.png

I read something interesting in the Microsoft documentation (https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/nf-wlanapi-wlanscan ):

The Wireless LAN Service does not send notifications when available wireless networks change. The Wireless LAN Service does not track changes to the list of available networks across multiple scans. The current default behavior is that the Wireless LAN Service only asks the wireless interface driver to scan for wireless networks every 60 seconds, and in some cases (when already connected to wireless network) the Wireless LAN Service does not ask for scans at all

Does this mean that even when I call WlanScan and WlanGetAvailableNetworkList functions to retrieve the list of networks, I would still not able to get updated list since scan is performed every 60 seconds?

So my question - Is my expectation correct that we can retrieve an updated list of WiFi network list if we call the said functions accordingly as soon as possible? If yes, what are the ways to do it?

Thank you!!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,523 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,231 Reputation points Microsoft Vendor
    2022-10-21T05:39:26.66+00:00

    As WlanScan said and you have mentioned, for Wireless LAN Service

    In some cases (when already connected to wireless network) the Wireless LAN Service does not ask for scans at all, and the current default behavior is that the Wireless LAN Service only asks the wireless interface driver to scan for wireless networks every 60 seconds in other cases.

    In order to track changes to the list of available networks across multiple scans,

    1.The application should first register for WLAN_NOTIFICATION_SOURCE_ACM notifications.
    2.The WlanScan function can then be called to initiate a scan. The application should then wait to receive the wlan_notification_acm_scan_complete notification or timeout after 4 seconds.
    3.Then the application can call the WlanGetNetworkBssList or WlanGetAvailableNetworkList function to retrieve a list of available wireless networks.

    This process can be repeated periodically with the application keeping tracking of changes to available wireless networks. For an example, please see Wlsample.

    0 comments No comments