private void ConnectForIntegrityCheck(ApConfigClient apConfigClient, int port, int streamBytes) { using (Wlan wlanApi = new Wlan()) { var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count)); var wlanInterface = wlanInterfaceList[0]; if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected) { return; } if (apConfigCreated == false) { var currentConfig1 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password"); var currentConfig2 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password"); ConfiguredSSIDs configuredSSID1 = new ConfiguredSSIDs("", ""); ConfiguredSSIDs configuredSSID2 = new ConfiguredSSIDs("", ""); if (apConfigClient.ApplyConfiguration(routers[0], currentConfig1, out configuredSSID1)) { currentConfig1.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID; currentConfig1.SSID_5GHZ = configuredSSID1.FiveghzSSID; testLogger.LogComment("Successfully applied the Configuration to AP[0]"); } else { testLogger.LogError("Unable to apply the configuration to AP [0]"); } testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Applying AP Configuration to AP[1] {0}", currentConfig2.SSID_24GHZ)); if (apConfigClient.ApplyConfiguration(routers[1], currentConfig2, out configuredSSID2)) { currentConfig2.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID; currentConfig2.SSID_5GHZ = configuredSSID1.FiveghzSSID; testLogger.LogComment("Successfully applied the Configuration to AP[2]"); } else { testLogger.LogError("Unable to apply the configuration to AP[2]"); } string profile1; string profile2; profile1 = currentConfig1.CreateProfile24ghz(ConnectionMode.Manual, false); profileName1 = currentConfig1.SSID_24GHZ; profile2 = currentConfig2.CreateProfile24ghz(ConnectionMode.Manual, false); profileName2 = currentConfig2.SSID_24GHZ; testLogger.LogComment(profile1); wlanApi.CreateProfile(wlanInterface.Id, profile1); wlanApi.CreateProfile(wlanInterface.Id, profile2); testLogger.LogComment("Wait to allow APs to beacon"); Wlan.Sleep(10000); apConfigCreated = true; } int retries = 3; while (retries > 0) { retries--; testLogger.LogComment("Scan"); wlanApi.TryScan(wlanInterface.Id, false, ScanWait); try { testLogger.LogComment(String.Format(CultureInfo.InvariantCulture, "Attempt to Connect to SSID : {0}", profileName1)); wlanApi.ProfileConnect(wlanInterface.Id, profileName1, ConnectWait); break; } catch (Exception) { testLogger.LogComment("Connect failed."); if (retries == 0) { testLogger.LogError(String.Format(CultureInfo.InvariantCulture, "Could not connect to SSID: {0}", profileName1)); return; } } } testLogger.LogComment("Wait for DHCP"); Microsoft.Test.Networking.Kit.Helpers.WaitForWlanConnectivity(wlanInterface.Id, 1000 * 15, testLogger); } }