예제 #1
0
        public IList<WiFiConnectedSensor> GetAllWiFiConnectedSensorData()
        {
            IList<WiFiConnectedSensor> sensors = new List<WiFiConnectedSensor>();
            try
            {
                using (var wifiApi = new JimbeWiFi(_version))
                {
                    logger.Debug("Getting wlan interfaces list");
                    var interfaceslist = wifiApi.WiFiEnumInterfaces();
                    foreach (WifiInterface wifiInterface in interfaceslist.Where(x => x.IsState==WifiInterface.WlanInterfaceState.connected))
                    {
                        logger.Debug("Getting current connected network ", wifiInterface.InterfaceGuid, " ", wifiInterface.Description);
                        var wiFiConnectedSensor = new WiFiConnectedSensor()
                            {
                                HistorySize = 5,
                                Weigth = ConnectedWeigth
                            };

                        try
                        {
                            var network = wifiApi.WiFiGetCurrentConnection(wifiInterface);

                            var wiFiNetworkSet = new WiFiNetworkSet()
                            {
                                Sensor = wiFiConnectedSensor
                            };

                            IList<WiFiNetwork> networks = new List<WiFiNetwork>();

                            networks.Add(new WiFiNetwork(network.Ssid, network.SignalQuality, wiFiNetworkSet));

                            wiFiNetworkSet.Networks = networks;

                             wiFiConnectedSensor.Datasets.Add(wiFiNetworkSet);
                            sensors.Add(wiFiConnectedSensor);
                        } catch (WifiException we)
                        {
                            logger.Error("Error in getting Network from wlan Interface: ", wifiInterface.InterfaceGuid, " ", wifiInterface.Description, " ", we.Message);
                        }
                    }
                }
            }
            catch (WifiToManyHandleException we)
            {
                logger.Error(we.Message);
            }
            catch (WifiException we)
            {
                logger.Error(we.Message);
            }
            return sensors;
        }
예제 #2
0
        static void Main(string[] args)
        {
            IEnumerable<WifiInterface> interfacelist;
            IEnumerator<WifiInterface> rator;
            int i=0;
            while (i++ < 100)
            {
                {

                }
                JimbeWiFi wifiApi = null;
                try
                {
                    wifiApi = new JimbeWiFi();
                }
                catch (WifiToManyHandleException)
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                using (wifiApi)
                {
                    interfacelist = wifiApi.WiFiEnumInterfaces();
                    rator = interfacelist.GetEnumerator();
                    while (rator.MoveNext())
                    {
                        Console.WriteLine("Interface Description: {0} GUID {1} State {2}", rator.Current.Description,
                                          rator.Current.InterfaceGuid, rator.Current.IsState);
                        IEnumerable<WifiNetwork> networkslist = wifiApi.WiFiGetAvailableNetworkList(rator.Current);
                        foreach (WifiNetwork net in networkslist)
                        {
                            Console.WriteLine("\nNetwork ssid= {0} Profile= {1} SignalPower={2} Network Type= {3} ",
                                              net.Ssid, net.Profile, net.SignalQuality, net.Type);
                            foreach (var macAddrs in net.Bssids)
                                Console.WriteLine("\nMAC address: {0}", macAddrs);
                        }
                        if (rator.Current.IsState == WifiInterface.WlanInterfaceState.connected)
                        {
                            var currentnetwork = wifiApi.WiFiGetCurrentConnection(rator.Current);
                            Console.WriteLine(
                                "\nCurrent Network ssid= {0} Profile= {1} SignalPower={2} Network Type= {3} ",
                                currentnetwork.Ssid, currentnetwork.Profile, currentnetwork.SignalQuality,
                                currentnetwork.Type);
                            foreach (var macAddrs in currentnetwork.Bssids)
                                Console.WriteLine(" MAC address: {0}", macAddrs);
                        }
                    }
                    System.Threading.Thread.Sleep(500);
                }
            }
        }
예제 #3
0
        public IList<WiFiSensor> GetAllWiFiSensorData()
        {
            IList<WiFiSensor> sensors = new List<WiFiSensor>();
            try
            {
                using (var wifiApi = new JimbeWiFi(_version))
                {
                    logger.Debug("Getting wlan interfaces list");
                    var interfaceslist = wifiApi.WiFiEnumInterfaces();
                    foreach (WifiInterface wifiInterface in interfaceslist)
                    {
                        var wiFiSensor = new WiFiSensor()
                            {
                                Weigth = NotConnectedWeigth,
                                HistorySize = 10
                            };
                        logger.Debug("Getting wlan networks list from interface ", wifiInterface.InterfaceGuid, " ", wifiInterface.Description);
                        try
                        {
                            var networkslist = wifiApi.WiFiGetAvailableNetworkList(wifiInterface);
                            var wiFiNetworkSet = new WiFiNetworkSet()
                                {
                                    Sensor = wiFiSensor
                                };

                            IList<WiFiNetwork> networks =
                                (from net in networkslist select new WiFiNetwork(net.Ssid, net.SignalQuality,wiFiNetworkSet)).ToList();

                            wiFiNetworkSet.Networks=networks;
                            wiFiSensor.Datasets.Add(wiFiNetworkSet);
                            sensors.Add(wiFiSensor);

                        } catch (WifiException we)
                        {
                            logger.Error("Error in getting networks from wlan Interface: ", wifiInterface.InterfaceGuid," ", wifiInterface.Description," ", we.Message);
                        }
                    }
                }
            }catch( WifiToManyHandleException we)
            {
                logger.Error(we.Message);
            } catch(WifiException we)
            {
                logger.Error(we.Message);
            }
            return sensors;
        }
        public void Setting_f()
        {
            JimbeWiFi tmp=new JimbeWiFi();

            Interfaces = new List<String>();//tmp.WiFiEnumInterfaces());

            foreach (var wifi in tmp.WiFiEnumInterfaces())
            {
                Interfaces.Add(wifi.InterfaceGuid.ToString());
            }

            Sensibilità = _sensibilitàSaved;
            Checkedconnected = _checkedconnectedsaved;
        }