Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }