emoacht / ManagedNativeWifi

A managed implementation of Native Wifi API
MIT License
139 stars 41 forks source link

Issue scanning for networks #55

Open mhemy opened 6 months ago

mhemy commented 6 months ago

When I scan the network using: await NativeWifi.ScanNetworksAsync(timeout: TimeSpan.FromSeconds(8)); This operation completes very quickly and does not look like it scanned, so I am assuming it just completes the process of starting the scanning threads, however does not complete the scanning. I am also not sure why, after the scan when I run EnumerateAvailableNetworkSsids(), it finds very few, sometimes only one SSID, yet on the windows OS it shows 20 available networks. Edit: "netsh wlan show networks" shows the same results, and also returns immediately. How can we force a real scan? Finally, ScanNetworksAsync() returns a list of interfaces that it scanned, but if I understand correctly, it does not return which one failed, completed, was cancelled, or was interrupted due to timeout being reached. Am I missing something?

emoacht commented 2 months ago

See the implementation of ScanNetworksAsync method. https://github.com/emoacht/ManagedNativeWifi/blob/949fe9ff83c0dc79b160992d96e8a9f5f08d4c77/Source/ManagedNativeWifi/NativeWifi.cs#L95C1-L182C1

I think it is self explanatory. Basically, it will instantiate wlan client which has an event to notify the received message and it will subscribe to it. It will also create a list of available wireless interfaces. Then, it will request each interfaces to perform scan. When scan complated or scan failed message comes from an interface, it will remove that interface from the list. When all interfaces finish to return the messages, it will return the GUID of complated interfaces.