private void AssociateSameAP(int routerIndex, bool b5Ghz, bool bHibernate) { Log("Deleting all wlan profiles"); DeleteProfiles(); Log("Starting Echo Services"); CreateEchoServer(); //Radios of all APs are turned on by the SetupRoutersIfNeeded(); Log("Setting up Routers"); SetupRoutersIfNeeded(); string Profile; APConfig apConfig = m_APConfigs[routerIndex]; string ap_ssid = (b5Ghz) ? apConfig.SSID_5GHZ : apConfig.SSID_24GHZ; //Turn off all APs SetRadioState(0, false, false); SetRadioState(0, false, true); SetRadioState(1, false, false); SetRadioState(1, false, true); //Turn on AP used for this run SetRadioState(routerIndex, true, b5Ghz); LogMajor("Associate with manual profile to " + ap_ssid + " - Enter lower powerstate - Wake - Verify connectivity to same AP"); Log("Creating a manual profile for SSID " + ap_ssid); Profile = CreateProfile(routerIndex, ConnectionMode.Manual, b5Ghz); LogMajor("Connecting to " + ap_ssid); if (!ConnectToAP(ap_ssid)) { return; } LogMajor("Validating association bssid"); if (!ValidateRadioAssociation(routerIndex, b5Ghz)) { return; } LogMajor("Validating connection by connecting to echo services and performing echo"); if (!PerformEcho(routerIndex, b5Ghz)) { return; } m_ApConfigClient.Disconnect(); //must disconnect from ap controller before going to sleep if (bHibernate) { LogMajor("Entering hibernate"); m_PowerManager.Sleep(120 * 1000, SleepState.S4); } else { LogMajor("Entering deepest supported sleep"); m_PowerManager.DeepestSleep(120 * 1000); } LogMajor("Sleeping for 30 seconds after wake up"); Wlan.Sleep(30 * 1000); // 30s m_ApConfigClient.Connect(); //must reconnect to ap controller after waking up if (!Helpers.IsConnected(m_WlanApi, m_TestInterface)) { LogError("After resuming system not connected to " + ap_ssid); return; } LogMajor("Validating association bssid"); if (!ValidateRadioAssociation(routerIndex, b5Ghz)) { return; } LogMajor("Validating connection by connecting to echo services and performing echo"); if (!PerformEcho(routerIndex, b5Ghz)) { return; } m_WlanApi.DeleteAllProfiles(m_TestInterface.Id); }
public void TestDot11wConnection() { Guid interfaceId; testLogger.LogComment("Testing 802.11w Connection to AP with SSID " + dot11wSSID + " and password " + dot11wPassword); 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]; interfaceId = wlanInterface.Id; // Delete Profile if present DisconnectAndDeleteProfile(wlanApi); // Scan testLogger.LogComment("Scan"); wlanApi.Scan(wlanInterface.Id, false, ScanWait); // Check to see if SSID is in scan list testLogger.LogComment("Check to see if SSID is in scan list"); var networkList = wlanApi.GetAvailableNetworkList(interfaceId); bool found = false; foreach (WlanNetwork network in networkList) { if (String.Compare(network.Ssid, dot11wSSID, StringComparison.Ordinal) == 0) { found = true; break; } } if (found == false) { testLogger.LogError("Could not find 11w router in scan list: " + dot11wSSID); testLogger.LogResult(TestResult.Failed); return; } else { testLogger.LogComment("Found the 11w router in the scan list: " + dot11wSSID); } // Create Profile string profile = GenerateProfile(); testLogger.LogComment("Creating Profile"); wlanApi.CreateProfile(interfaceId, profile); // Connect testLogger.LogComment("Connecting to AP"); wlanApi.ProfileConnect(interfaceId, dot11wSSID, new TimeSpan(0, 0, 30)); } // Check MFP Status bool mfpStatus = IsMfpNeogotiated(interfaceId); testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus); if (mfpStatus == false) { testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false"); testLogger.LogResult(TestResult.Failed); return; } if (enableSleepTest) { PowerManager powerManager; powerManager = new PowerManager(); // Wait for DHCP Stable testLogger.LogComment("Wait for DHCP to be stable"); Wlan.Sleep(1000 * 60 * 2); testLogger.LogComment("Going into Connected standby/Sleep for 1 minute"); powerManager.DeepestSleep(60); using (Wlan wlanApi = new Wlan()) { bool isConnected = IsConnected(wlanApi); if (isConnected == false) { testLogger.LogError("After waking from connected standby the device is no longer connected to the AP"); } else { testLogger.LogComment("After waking from connected standby the device is still connected to the AP"); } } // Check MFP Status mfpStatus = IsMfpNeogotiated(interfaceId); testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus); if (mfpStatus == false) { testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false"); return; } } }