Example #1
0
        private void AssociateDifferentAP(int firstRouterIndex, int secondRouterIndex, bool b5GhzFirstRouter, bool b5GhzSecondRouter, 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 ap1Config = m_APConfigs[firstRouterIndex];
            APConfig ap2Config = m_APConfigs[secondRouterIndex];
            string   ap1_ssid  = (b5GhzFirstRouter) ? ap1Config.SSID_5GHZ : ap1Config.SSID_24GHZ;
            string   ap2_ssid  = (b5GhzSecondRouter) ? ap2Config.SSID_5GHZ : ap2Config.SSID_24GHZ;
            string   ap2_bssid = (b5GhzSecondRouter) ? ap2Config.BSSID_5GHZ : ap2Config.BSSID_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(firstRouterIndex, true, b5GhzFirstRouter);

            LogMajor("Associate with manual profile to " + ap1_ssid + " - Enter lower powerstate turn off first AP and turn on second AP - Wake - Connect with manual profile to " + ap2_ssid);

            Log("Creating a manual profile for SSID " + ap1_ssid);
            Profile = CreateProfile(firstRouterIndex, ConnectionMode.Manual, b5GhzFirstRouter);

            LogMajor("Connecting to " + ap1_ssid);
            if (!ConnectToAP(ap1_ssid))
            {
                return;
            }

            LogMajor("Validating association bssid");
            if (!ValidateRadioAssociation(firstRouterIndex, b5GhzFirstRouter))
            {
                return;
            }
            LogMajor("Validating connection by connecting to echo services and performing echo");
            if (!PerformEcho(firstRouterIndex, b5GhzFirstRouter))
            {
                return;
            }

            int delayInSeconds = 30;
            int ScenarioToRun  = 1;

            //switch
            LogMajor("Putting machine into lower power state for 2 minutes. " + ap1_ssid + " will turn off and " + ap2_ssid + "will turn on");
            m_ApConfigClient.StartApScenarioAssoc(m_Routers[secondRouterIndex], m_Routers[firstRouterIndex], ScenarioToRun, delayInSeconds, b5GhzSecondRouter, b5GhzFirstRouter);

            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

            //scan for new AP
            Helpers.IssueScanWaitForSSIDToAppearInScanList(m_WlanApi, m_TestInterface, ap2_ssid, ap2_bssid, 60, 500);

            //connect to next AP.
            Log("Creating a manual profile for SSID " + ap2_ssid);
            Profile = CreateProfile(secondRouterIndex, ConnectionMode.Manual, b5GhzSecondRouter);

            LogMajor("Connecting to " + ap2_ssid);
            if (!ConnectToAP(ap2_ssid))
            {
                return;
            }

            LogMajor("Validating association bssid");
            if (!ValidateRadioAssociation(secondRouterIndex, b5GhzSecondRouter))
            {
                return;
            }
            LogMajor("Validating connection by connecting to echo services and performing echo");
            if (!PerformEcho(secondRouterIndex, b5GhzSecondRouter))
            {
                return;
            }

            m_WlanApi.DeleteAllProfiles(m_TestInterface.Id);
        }