4

I'm trying to create program that connects to certain wifi network when it's in range, even if already connected to another wifi.

I'm using SimpleWifi, and basically it works great. Except that it does not see new wifi networks before I clicked wifi icon in Windows 10 taskbar to show list of networks.

How can I force c# program to update wifi network list?

Currently using IEnumerable<AccessPoint> accessPoints = wifi.GetAccessPoints().OrderByDescending(ap => ap.SignalStrength); to update wifi networks, but as I said, it does not see new networks before refreshed manually from Windows.

darx
  • 1,417
  • 1
  • 11
  • 25

2 Answers2

2

It's almost 3 years ago but here is my take on this issue anyways.

In that library you can call: SimpleWifi.Wifi.Disconnect()

Which I do before re-connect and get the list of access points again. This works sort of, new networks introduced after windows discovery does actually show up, but are way slower than if you click "wifi" button in Windows, which will bring up newly discovered networks right away.

If someone knows a solution to "trigger" Windows/Managed wifi connections to update it's list, just like you do in Windows, I would appreciate that

1

SimpleWifi, like other Wifi libraries have this feature built-in. And its required as Windows does not always show all the wifi networks available correctly, unless queried..

the sample code can be found here: https://pastebin.com/1iCp41SP , not the most elegant code , but worked in a WPF project. This part of the code scans/refreshes the Wifi List in SimpleWifi

    var testClient = new WlanClient();
    foreach (WlanInterface wlanIface in testClient.Interfaces)
    {
       wlanIface.Scan();
    }
Denis G. Labrecque
  • 1,023
  • 13
  • 29
Tom
  • 11
  • 3
  • This is the correct answer. Voted for the previous one because it looked like a quick fix, but didn't actually work in practice. This works. – Denis G. Labrecque Aug 15 '22 at 15:22