Main Site Documentation

WiFi UEXT module not working


#1

Hi.

We’re trying to use an Olimex Mod-Wifi UEXT module on a FEZ-Cobra board, by running following (coming from standard GHI documentation, updated a little to provide the missing parameter on WiFi.Enable() method):


/// Add these libraries to your project's References
/// System
/// Microsoft.SPOT.Hardware
/// Microsoft.SPOT.Net
/// GHIElectronics.NETMF.System
/// GHIElectronics.NETMF.Net
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Net.NetworkInformation;
using GHIElectronics.NETMF.Net;
using Microsoft.SPOT.Hardware;
using System.Net;
using GHIElectronics.NETMF.FEZ;

namespace WiFi_Example4._0
{
    public class Program
    {
        static public bool wifi_event = false;
        static public bool wifi_last_status = false;
        static public bool network_is_read = false;

        static public ManualResetEvent NetworkAvailablityBlocking = null;

        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
            if (!WiFi.IsEnabled)
            {
                WiFi.Enable(WiFi.HardwareModule.ZG100M_Compatible, SPI.SPI_module.SPI2,
                    (Cpu.Pin)FEZ_Pin.Digital.UEXT10,
                    (Cpu.Pin)FEZ_Pin.Digital.UEXT5,
                    (Cpu.Pin)FEZ_Pin.Digital.UEXT6);// EMX DevSys
            }

            // WiFi settings
            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
            Wireless80211 WiFiSettings = null;
            for (int index = 0; index < netif.Length; ++index)
            {
                if (netif[index] is Wireless80211)
                {
                    WiFiSettings = (Wireless80211)netif[index];

                }
            }

            if (WiFiSettings.Ssid != "my_ssid")
            {
                WiFiSettings.Ssid = "my_ssid";
                WiFiSettings.PassPhrase = "my_pass";
                WiFiSettings.Encryption = Wireless80211.EncryptionType.WPA;
                Wireless80211.SaveConfiguration(new Wireless80211[] { WiFiSettings }, false);
            }
            NetworkAvailablityBlocking = new ManualResetEvent(false);
            if (!WiFi.IsLinkConnected)
            {
                Debug.Print("Waiting for WiFi link!");
                NetworkAvailablityBlocking.Reset();
                while (!NetworkAvailablityBlocking.WaitOne(5000, false))
                {
                    if (!WiFi.IsLinkConnected)
                    {
                        Debug.Print("WiFi link is not available yet! Wrong AP settings?");
                        Debug.Print("Still waiting.");
                    }
                    else
                        break;
                }
            }
            Debug.Print("WiFi link is ready!");

            Debug.Print("Enable DHCP");
            try
            {
                if (!WiFiSettings.IsDhcpEnabled)
                    WiFiSettings.EnableDhcp();// This function is blocking
                else
                {
                    WiFiSettings.RenewDhcpLease();// This function is blocking
                }
                network_is_read = true;
                Debug.Print("Network settings:");
                Debug.Print("IP Address: " + WiFiSettings.IPAddress);
                Debug.Print("Subnet Mask: " + WiFiSettings.SubnetMask);
                Debug.Print("Default Getway: " + WiFiSettings.GatewayAddress);
                Debug.Print("DNS Server: " + WiFiSettings.DnsAddresses[0]);
            }
            catch
            {
                Debug.Print("DHCP Faild");
            }

            Debug.Print("Test DNS");
            try
            {
                IPHostEntry myIP = Dns.GetHostEntry("www.ghielectronics.com");

                if (myIP != null)
                {
                    Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
                }
            }
            catch
            {
                Debug.Print("Faild to Get the host entry of the FQN from DNS server!");
            }

            Thread.Sleep(Timeout.Infinite);
        }


        // This call back will be called when any change occures on Ethernet cable connection or WiFi physical link.
        // Also it reports PPP connection status if PPP is enabled.
        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            if (e.IsAvailable)
            {
                if (WiFi.IsLinkConnected)
                {
                    if (wifi_last_status != true)
                    {
                        wifi_last_status = true;
                        NetworkAvailablityBlocking.Set();
                    }
                }
            }
            else
            {
                if (!WiFi.IsLinkConnected)
                {
                    if (wifi_last_status != false)
                    {
                        wifi_last_status = false;
                        network_is_read = false;
                    }
                }
            }
        }

    }
}

But WiFi.IsLinkConnected is always false!

Of course, we double checked for mispelled SSID, password and encryption type used.

Any suggestions?


#2

What is this? A link please.


#3

Picture shows a ZG module, but now there is a MRF24WB0MA, pin-compatible, as far as I know.


#4

That looks like it would work but we never tested it and we do not know the pinout.

Note that zerog support will be dropped in future in favor of the new redpine support.