예제 #1
0
        public void Scan()
        {
            Log("Scan Test Configuration Parameters: ");
            Log(m_AP1Config24GHz.GetTestParameter());
            Log(m_AP1Config5GHz.GetTestParameter());
            Log(m_AP2Config24GHz.GetTestParameter());
            Log(m_AP2Config5GHz.GetTestParameter());

            SetupRouters();
            // Turn on all Radios
            Log("Turning on all radios");
            AC.SetRadio24GHzState(routers[0], true);
            AC.SetRadio24GHzState(routers[1], true);
            AC.SetRadio5GHzState(routers[0], true);
            AC.SetRadio5GHzState(routers[1], true);

            LogMajor("Turning on Airplane Mode");
            Api.SetRadioState(TestInterface, false);

            EventHandler <EventArrivedEventArgs> ETWCallback = null;

            ETWCallback = (object sender, EventArrivedEventArgs properties) =>
            {
                LogEtwEvent(properties);
            };

            var wlanEtwWatcher = new WlanEtwWatcher();

            wlanEtwWatcher.EventArrived += ETWCallback;
            Log("Start ETW Tracing");
            wlanEtwWatcher.Start();

            bool Radio_0_24Ghz_Found = false;
            bool Radio_1_24Ghz_Found = false;
            bool Radio_0_5Ghz_Found  = false;
            bool Radio_1_5Ghz_Found  = false;

            string Reason_Radio_0_24Ghz_Found = null;
            string Reason_Radio_1_24Ghz_Found = null;
            string Reason_Radio_0_5Ghz_Found  = null;
            string Reason_Radio_1_5Ghz_Found  = null;

            try
            {
                Log("Sleeping for a second");
                Wlan.Sleep(1 * 1000); // 1s

                LogMajor("Turning off Airplane Mode");
                Api.SetRadioState(TestInterface, true);

                for (int i = 0; i < 4; i++)
                {
                    Log("Scan Iteration " + i);

                    if (i == 0)
                    {
                        // First scan is always with a flush so that we dont get old data
                        LogMajor("Calling (public) scan with flush");
                        Api.Scan(TestInterface.Id, true, new TimeSpan(0, 0, 10));
                    }
                    else if (ScanningConfiguration.IssueMulitpleScans == true)
                    {
                        // Additional scans are without flush
                        LogMajor("Calling (internal) scan without flush");
                        Api.Scan(TestInterface.Id, false, new TimeSpan(0, 0, 10));
                    }

                    // If any network is marked hidden, we need to specifically search for those
                    for (int j = 0; j < 2; j++)
                    {
                        if (APConfigs[j].BeaconEnabled_24GHZ == false)
                        {
                            LogMajor("Calling (public) scan for " + APConfigs[j].SSID_24GHZ);
                            Api.Scan(TestInterface.Id, false, APConfigs[j].SSID_24GHZ, new TimeSpan(0, 0, 10));
                        }
                        if (APConfigs[j].BeaconEnabled_5GHZ == false)
                        {
                            LogMajor("Calling (public) scan for " + APConfigs[j].SSID_5GHZ);
                            Api.Scan(TestInterface.Id, false, APConfigs[j].SSID_5GHZ, new TimeSpan(0, 0, 10));
                        }
                    }

                    if (!Radio_0_24Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[0].SSID_24GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[0], false, out Reason_Radio_0_24Ghz_Found))
                        {
                            LogMajor(APConfigs[0].SSID_24GHZ + "found in scan list ");
                            Radio_0_24Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[0].SSID_24GHZ);
                        }
                    }

                    if (!Radio_1_24Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[1].SSID_24GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[1], false, out Reason_Radio_1_24Ghz_Found))
                        {
                            LogMajor(APConfigs[1].SSID_24GHZ + "found in scan list ");
                            Radio_1_24Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[1].SSID_24GHZ);
                        }
                    }

                    if (!ScanningConfiguration.DeviceSupports5Ghz)
                    {
                        if (Radio_0_24Ghz_Found && Radio_1_24Ghz_Found)
                        {
                            LogMajor("Scan: Located all routers");
                            return;
                        }
                        else
                        {
                            LogMajor("Scan: Not yet located all routers ");
                            LogMajor("Router 0 2.4Ghz Found =" + Radio_0_24Ghz_Found);
                            LogMajor("Router 1 2.4Ghz Found =" + Radio_1_24Ghz_Found);
                            continue; // skip 5Ghz
                        }
                    }



                    if (!Radio_0_5Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[0].SSID_5GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[0], true, out Reason_Radio_0_5Ghz_Found))
                        {
                            LogMajor(APConfigs[0].SSID_5GHZ + " found in scan list");
                            Radio_0_5Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[0].SSID_5GHZ);
                        }
                    }

                    if (!Radio_1_5Ghz_Found)
                    {
                        LogMajor("Scan : Locating " + APConfigs[1].SSID_5GHZ + " in bssid list");
                        if (Helpers.ValidateNetworkVisible(Api, APConfigs[1], true, out Reason_Radio_1_5Ghz_Found))
                        {
                            LogMajor(APConfigs[1].SSID_5GHZ + " found in scan list");
                            Radio_1_5Ghz_Found = true;
                        }
                        else
                        {
                            LogMajor("ValidateNetworkVisible failed for " + APConfigs[1].SSID_5GHZ);
                        }
                    }

                    if (Radio_0_24Ghz_Found &&
                        Radio_1_24Ghz_Found &&
                        Radio_0_5Ghz_Found &&
                        Radio_1_5Ghz_Found)
                    {
                        LogMajor("Scan: Located all routers");
                        return;
                    }

                    LogMajor("Scan: Not yet located all routers ");
                    LogMajor("Router 0 2.4Ghz Found =" + Radio_0_24Ghz_Found);
                    LogMajor("Router 1 2.4Ghz Found =" + Radio_1_24Ghz_Found);
                    LogMajor("Router 0 5Ghz Found =" + Radio_0_5Ghz_Found);
                    LogMajor("Router 1 5Ghz Found =" + Radio_1_5Ghz_Found);
                }
            }
            catch (Exception error)
            {
                LogMajor(error.ToString());
                throw;
            }
            finally
            {
                wlanEtwWatcher.Dispose();
            }


            LogMajor("Error locating all routers");
            if (!Radio_0_24Ghz_Found)
            {
                LogMajor("Scanning - " + Reason_Radio_0_24Ghz_Found);
                throw new Exception(Reason_Radio_0_24Ghz_Found);
            }
            if (!Radio_1_24Ghz_Found)
            {
                LogMajor("Scanning - " + Reason_Radio_1_24Ghz_Found);
                throw new Exception(Reason_Radio_1_24Ghz_Found);
            }

            if (ScanningConfiguration.DeviceSupports5Ghz)
            {
                if (!Radio_0_5Ghz_Found)
                {
                    LogMajor("Scanning - " + Reason_Radio_0_5Ghz_Found);
                    throw new Exception(Reason_Radio_0_5Ghz_Found);
                }
                if (!Radio_1_5Ghz_Found)
                {
                    LogMajor("Scanning - " + Reason_Radio_1_5Ghz_Found);
                    throw new Exception(Reason_Radio_1_5Ghz_Found);
                }
            }
        }