Connect to hidden (non-broadcast) network using c#?

落花浮王杯 提交于 2020-07-11 04:43:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!