Пример #1
0
        private Program()
        {
            OneTimeConfig();

            _lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
            Touch.Initialize(this);

            this.MainWindow = new Window();
            this.MainWindow.TouchDown += MainWindow_TouchDown;
            this.MainWindow.TouchUp += MainWindow_TouchUp;
            this.MainWindow.TouchMove += MainWindow_TouchMove;

            var eth = new EthernetBuiltIn();
            eth.Open();
            if (!eth.CableConnected)
            {
                eth.Close();
                var wifi = new WiFiRS9110(SPI.SPI_module.SPI1, G400.PD13, G400.PD12, G400.PD15);
                _netif = wifi;
                _netif.Open();
                wifi.Join("XXX", "XXX");
            }
            else
            {
                _netif = eth;
            }
            if (!_netif.IsDhcpEnabled)
                _netif.EnableDhcp();
            if (!_netif.IsDynamicDnsEnabled)
                _netif.EnableDynamicDns();

            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
        }
        public static void initWiFi(WiFiRS9110 wifi, String ssid, String passphrase)
        {
            if (!wifi.IsOpen)
                wifi.Open();
            wifi.NetworkInterface.EnableDhcp();
            NetworkInterfaceExtension.AssignNetworkingStackTo(wifi);

            /*
            wifi.WirelessConnectivityChanged +=
                new WiFiRS9110.WirelessConnectivityChangedEventHandler(Interface_WirelessConnectivityChanged);
            wifi.NetworkAddressChanged +=
               new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);
            */

            // Scan for networks and connect if found
            WiFiNetworkInfo[] ScanResp = wifi.Scan();
            int i = 0;
            foreach (WiFiNetworkInfo info in ScanResp)
            {
                Debug.Print("Found WLAN: " + i + ", " + info.SSID);
                if (info.SSID.ToString().Equals(ssid))
                {
                    wifi.Join(ScanResp[i], passphrase);
                    break;
                }
                i++;
            }
        }
Пример #3
0
        public WiFiManager(WiFiRS9110 wifi, string ssid, string password)
        {
            this.wifi = wifi;
            this.ssid = ssid;
            this.password = password;

            wifi.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_WirelessConnectivityChanged);
            wifi.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(wifi_NetworkAddressChanged);
        }
Пример #4
0
        public WiFiManager(WiFiRS9110 wifi, string ssid, string password)
        {
            this.wifi     = wifi;
            this.ssid     = ssid;
            this.password = password;

            wifi.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_WirelessConnectivityChanged);
            wifi.NetworkAddressChanged       += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(wifi_NetworkAddressChanged);
        }
Пример #5
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public WiFiRS21(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            socket.ReservePin(Socket.Pin.Three, this);
            socket.ReservePin(Socket.Pin.Four, this);
            socket.ReservePin(Socket.Pin.Six, this);

            this.spi = GTI.SpiFactory.Create(socket, null, GTI.SpiSharing.Exclusive, socket, Socket.Pin.Six, this);
            this.networkInterface = new WiFiRS9110(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[3], socket.CpuPins[4], 4000);

            this.NetworkSettings = this.networkInterface.NetworkInterface;
        }
Пример #6
0
        public WifiRS21()
        {
            _annunciator = (IAnnunciator)DiContainer.Instance.Resolve(typeof(IAnnunciator));

            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;

            _wifi = new WiFiRS9110(
                GHI.Pins.FEZSpider.Socket6.SpiModule,
                GHI.Pins.FEZSpider.Socket6.Pin6,
                GHI.Pins.FEZSpider.Socket6.Pin3,
                GHI.Pins.FEZSpider.Socket6.Pin4,
                24000);
            _wifi.Open();
            _wifi.EnableDhcp();
            _wifi.EnableDynamicDns();
        }
Пример #7
0
        public WiFi(WiFi_RS21 module)
        {
            wifi = module.Interface;

            if (!wifi.IsOpen)
            {
                wifi.Open();
            }

            wifi.NetworkInterface.EnableDhcp();
            NetworkInterfaceExtension.AssignNetworkingStackTo(wifi);

            module.NetworkDown +=
                new GTM.Module.NetworkModule.NetworkEventHandler(Wifi_NetworkDown);
            module.NetworkUp +=
                new GTM.Module.NetworkModule.NetworkEventHandler(Wifi_NetworkUp);
            wifi.WirelessConnectivityChanged +=
                new WiFiRS9110.WirelessConnectivityChangedEventHandler(Interface_WirelessConnectivityChanged);
            wifi.NetworkAddressChanged +=
                new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);
        }
Пример #8
0
        private Program()
        {
            var eth = new EthernetBuiltIn();
            eth.Open();
            if (!eth.CableConnected)
            {
                eth.Close();
                var wifi = new WiFiRS9110(SPI.SPI_module.SPI2, G120E.Gpio.P3_30, G120E.Gpio.P2_30, G120E.Gpio.P4_31);
                _netif = wifi;
                _netif.Open();
                wifi.Join("XXX", "XXX");
            }
            else
            {
                _netif = eth;
            }
            if (!_netif.IsDhcpEnabled)
                _netif.EnableDhcp();
            if (!_netif.IsDynamicDnsEnabled)
                _netif.EnableDynamicDns();

            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
        }
Пример #9
0
        private void wifi_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            Debug.Print("Network Availability Event Triggered");

            if (wifi.IsActivated) // make sure that the event is fired by WiFi interface, not other networking interface.
            {

                if (e.IsConnected)
                {
                    if (wifi.IsLinkConnected)
                    {
                        //blocker.Set();
                        Debug.Print("WiFi connection was established!");

                        if (Started != null)
                            Started(this, EventArgs.Empty);
                    }
                }
                else
                {
                    if (!wifi.IsLinkConnected)
                    {
                        //blocker.Set();
                        Debug.Print("WiFi connection was dropped or disconnected!");

                        if (Stopped != null)
                            Stopped(this, EventArgs.Empty);
                    }
                }
            }
        }
Пример #10
0
 void wifi_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
 {
     // connect to orchestrator
     orchestratorJSClient.connect(host, port);
 }