Exemplo n.º 1
0
        public static void Main()
        {
            Debug.WriteLine("Welcome to WiFI Soft AP world!");

            GpioPin setupButton = GpioController.GetDefault().OpenPin(SETUP_PIN);

            setupButton.SetDriveMode(GpioPinDriveMode.InputPullUp);

            // If Wireless station is not enabled then start Soft AP to allow Wireless configuration
            // or Button pressed
            if (!Wireless80211.IsEnabled() || (setupButton.Read() == GpioPinValue.Low))
            {
                Wireless80211.Disable();

                if (WirelessAP.Setup() == false)
                {
                    // Reboot device to Activate Access Point on restart
                    Debug.WriteLine($"Setup Soft AP, Rebooting device");
                    Power.RebootDevice();
                }

                Debug.WriteLine($"Running Soft AP, waiting for client to connect");
                Debug.WriteLine($"Soft AP IP address :{WirelessAP.GetIP()}");

                // Link up Network event to show Stations connecting/disconnecting to Access point.
                NetworkChange.NetworkAPStationChanged += NetworkChange_NetworkAPStationChanged;;
            }
            else
            {
                Debug.WriteLine($"Running in normal mode, connecting to Access point");
                string IpAdr = Wireless80211.WaitIP();
                Debug.WriteLine($"Connected as {IpAdr}");
            }


            // Just wait for now
            // Here you would have the reset of your program using the client WiFI link
            Thread.Sleep(Timeout.Infinite);
        }