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++;
            }
        }
Пример #2
0
        private bool OpenWiFi()
        {
            try
            {
                if (!wifi.IsOpen)
                {
                    wifi.Open();
                }
            }
            catch (NetworkInterfaceExtensionException e)
            {
                switch (e.errorCode)
                {
                case NetworkInterfaceExtensionException.ErrorCode.AlreadyActivated: break;

                case NetworkInterfaceExtensionException.ErrorCode.HardwareFirmwareVersionMismatch:
                    wifi.UpdateFirmware();
                    wifi.Open();
                    break;

                case NetworkInterfaceExtensionException.ErrorCode.HardwareCommunicationFailure:
                case NetworkInterfaceExtensionException.ErrorCode.HardwareNotEnabled:
                case NetworkInterfaceExtensionException.ErrorCode.HardwareCommunicationTimeout:
                    Debug.Print("Error Message: " + e.ErrorMsg);
                    Debug.Print("Check WiFi module hardware connections and SPI/signals configurations.");
                    wifi.Open();
                    break;

                default:
                    Debug.Print("Error Message: " + e.ErrorMsg);
                    return(false);
                }
            }
            catch (Exception e)
            {
                Debug.Print("EnableWiFi Error: " + e.Message);
                return(false);
            }

            //NetworkInterfaceExtension.AssignNetworkingStackTo(wifi);
            Debug.Print("\nEnabled successfully!\nAt this point, the on-board LED on RS9110_N_11_21_1_Compatible module is ON.\n");
            return(true);
        }
Пример #3
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();
        }
Пример #4
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);
        }