public async Task <WiFiConnectionResult> ConnectAsync(WiFiNetworkDisplay network, WiFiReconnectionKind reconnectionKind, string password) { WiFiConnectionResult result; ReconnectionKind = reconnectionKind; if (network.AvailableNetwork.SecuritySettings.NetworkAuthenticationType == Windows.Networking.Connectivity.NetworkAuthenticationType.Open80211) { result = await _firstAdapter.ConnectAsync(network.AvailableNetwork, reconnectionKind); } else { // Only the password potion of the credential need to be supplied var credential = new PasswordCredential { Password = password }; result = await _firstAdapter.ConnectAsync(network.AvailableNetwork, reconnectionKind, credential); } // Since a connection attempt was made, update the connectivity level displayed for each foreach (var net in NetworkCollection) { net.UpdateConnectivityLevel(); } return(result); }
public void Save(WiFiReconnectionKind reconnectionKind, WiFiNetworkDisplay network, string deviceId, string password) { try { using (var writer = new BinaryWriter(new FileStream(_settingsFilePath, FileMode.Create))) { writer.Write((byte)reconnectionKind); writer.Write(password); writer.Write(deviceId); writer.Write(network.AvailableNetwork.Bssid); writer.Write(network.AvailableNetwork.Ssid); } } catch (Exception e) { Debug.WriteLine("Could not save WiFiSettings"); } }