예제 #1
0
파일: Program.cs 프로젝트: Nivade/insite
        private static void WifiDetection(WlanClient client)
        {
            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {
                Wlan.WlanBssEntry[] wlanBssEntries = wlanIface.GetNetworkBssList();


                foreach (Wlan.WlanBssEntry network in wlanBssEntries)
                {
                    int    rss     = network.rssi;
                    byte[] macAddr = network.dot11Bssid;
                    string tMac    = "";

                    for (int i = 0; i < macAddr.Length; i++)
                    {
                        tMac += macAddr[i].ToString("x2").PadLeft(2, '0').ToUpper();
                    }
                    string SSID = Encoding.ASCII.GetString(network.dot11Ssid.SSID).ToString();

                    if (ssidtest == SSID)
                    {
                        if (Data.Length < 170)
                        {
                            Data += network.linkQuality;
                            Data += ";";
                            Data += tMac;
                            Data += ";";
                        }
                    }
                }
            }
            //Console.WriteLine(Data);
            controller.SendData(Data);
            Data = "";
        }
예제 #2
0
파일: Program.cs 프로젝트: Nivade/insite
        private static void Main(string[] args)
        {
            // Get all available ports, so you know where you can choose from
            string[] ports = SerialPort.GetPortNames();
            Console.WriteLine("The following serial ports were found:");
            foreach (string port in ports)
            {
                Console.Write(port + ";");
            }
            Console.WriteLine(); // So the next text will start on a new line
            Console.WriteLine("Input the port number of the arduino.");
            string portNumber = Console.ReadLine();

            controller = new ArduinoControllerMain("COM" + portNumber);
            controller.SendData("RESET");
            string ownMac = client.Interfaces[0].NetworkInterface.GetPhysicalAddress().ToString();

            Console.WriteLine("Own MAC Address = " + ownMac);
            while (controller.ReceivedData() != "GET_ID")
            {
                ;
            }
            Console.WriteLine("Voer een netwerknaam in (e.g. fontysWPA): ");

            ssidtest = Console.ReadLine();
            {
                int length = ssidtest.Length;
                for (int i = 0; i < (32 - length); i++)
                {
                    ssidtest += '\0';
                }
            }

            DataTimer.Elapsed += OnTimedEvent;
            DataTimer.Start();
            controller.SendData("id:" + ownMac);
            Thread.Sleep(5000);
            OnTimedEvent(null, null);

            while (!quit)
            {
                Thread.Sleep(1000);
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: Nivade/insite
        private static void Main(string[] args)
        {
            // Get all available ports, so you know where you can choose from
            string[] ports = SerialPort.GetPortNames();
            Console.WriteLine("The following serial ports were found:");
            foreach (string port in ports)
            {
                Console.Write(port + ";");
            }
            Console.WriteLine(); // So the next text will start on a new line
            Console.WriteLine("Input the port number of the arduino.");
            string portNumber = Console.ReadLine();
            controller = new ArduinoControllerMain("COM" + portNumber);
            controller.SendData("RESET");
            string ownMac = client.Interfaces[0].NetworkInterface.GetPhysicalAddress().ToString();
            Console.WriteLine("Own MAC Address = " + ownMac);
            while (controller.ReceivedData() != "GET_ID") ;
            Console.WriteLine("Voer een netwerknaam in (e.g. fontysWPA): ");

            ssidtest = Console.ReadLine();
            {
                int length = ssidtest.Length;
                for (int i = 0; i < (32 - length); i++)
                {
                    ssidtest += '\0';
                }
            }

            DataTimer.Elapsed += OnTimedEvent;
            DataTimer.Start();
            controller.SendData("id:" + ownMac);
            Thread.Sleep(5000);
            OnTimedEvent(null, null);

            while (!quit)
            {
                Thread.Sleep(1000);
            }
        }