Ejemplo n.º 1
0
        public static void Main()
        {
            var port = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One);
            var wifi = new Esp8266WifiDevice(port, _rfPower, null);

            wifi.EnableDebugOutput = true;
            //wifi.EnableVerboseOutput = true;

            wifi.Mode = OperatingMode.Station;
            wifi.Connect("XXX", "XXX");

            Debug.Print("Version before update : ");
            foreach (var line in wifi.Version)
            {
                Debug.Print(line);
            }
            Debug.Print("------------------------");

            wifi.Update((progress) => { Debug.Print("Update progress : " + progress); });

            Debug.Print("Version after update : ");
            foreach (var line in wifi.Version)
            {
                Debug.Print(line);
            }
            Debug.Print("------------------------");

            int iCounter = 0;
            bool state = true;
            while (true)
            {
                _userLed.Write(state);
                state = !state;
                ++iCounter;
                if (iCounter % 10 == 0)
                {
                    Debug.Print("Current UTC time : " + DateTime.UtcNow);
                    iCounter = 0;
                }
                Thread.Sleep(500);
            }
        }