Exemple #1
0
        //*******************************Main activity is controlled by this code********************
        public void MainActivity()
        {
            Wlan.WlanAvailableNetwork[] sortedNetworks;
            WlanClient.WlanInterface[]  wlanIface;
            while (true)
            {
                this.connected = false;
                this.client    = new WlanClient();
                wlanIface      = client.Interfaces;
                foreach (var iface in wlanIface)
                {
                    Wlan.WlanAvailableNetwork[] Networks = iface.GetAvailableNetworkList(0);
                    sortedNetworks = Networks.OrderByDescending(x => x.wlanSignalQuality).ToArray();
                    foreach (Wlan.WlanAvailableNetwork network in sortedNetworks)
                    {
                        //Console.Write("\nSearching for available profiles..");
                        Wlan.Dot11Ssid ssid        = network.dot11Ssid;
                        string         networkName = (this.GetStringForSSID(ssid));
                        //Console.Write("\nStrongest Signal from: " + networkName);
                        string filename = this.location + "/" + networkName + ".xml";
                        string profileXML;
                        if (System.IO.File.Exists(filename))
                        {
                            profileXML = System.IO.File.ReadAllText(@filename);
                            //System.Console.Write(profileXML);

                            try
                            {
                                iface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXML, true);
                                iface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, networkName);
                                //Console.Write("\nConnection Successful..................");
                                //Console.Write("\nGoing To Stop for 10 Seconds....");
                                this.connected = true;
                                System.Threading.Thread.Sleep(10000);
                                //Console.Write("\nWait Over...");
                            }
                            catch
                            {
                                this.connected = false;
                            }
                        }
                        if (this.connected)
                        {
                            break;
                        }
                    }
                    if (this.connected)
                    {
                        break;
                    }
                }
                if (this.connected)
                {
                    break;
                }
            }
        }
Exemple #2
0
 internal WlanInterface(WlanClient client, Wlan.WlanInterfaceInfo info)
 {
     this.client = client;
     this.info   = info;
 }