问题
I am looking for a way to connect to a non-broadcast (hidden) network via C#. This is a new area of development for me. It is a UWP application that needs to be able to manage WiFi connections. I am currently using the Windows.Devices.Wifi namespace to do pretty much everything else, but I don't know how to do the non-broadcast. I have the SSID and the password for the network. I might be missing something, and it could be really easy to do, but I am missing something. Anyone able to help me out?
回答1:
You can use bssid to get the WiFiAvailableNetwork like I have done:-
await wifiAdapter.ScanAsync(); var wifiList= wifiList.AddRange(wifiAdapter.NetworkReport.AvailableNetworks.ToList());
WiFiAvailableNetwork targetWifi = wifiList.FirstOrDefault(x => x.Bssid.Equals("00:19:a9:7f:08:a0"));
回答2:
According to the documentation, this can be done with the WiFiAdapter.ConnectAsync method.
public IAsyncOperation<WiFiConnectionResult> ConnectAsync(
WiFiAvailableNetwork availableNetwork,
WiFiReconnectionKind reconnectionKind,
PasswordCredential passwordCredential,
string ssid
)
Connect this Wi-Fi device to a hidden network, with the given passphrase and reconnection policy.
来源:https://stackoverflow.com/questions/37348699/connect-to-hidden-non-broadcast-network-using-c