Main Site Documentation

Wifi on Fez Cobra with EMX module


#1

Hello,

I’m using a wifi expansion module of Olimex with an zg2100 compatible Wifi module on it and a UEXT connector.

I have connected to UEXT connector on the Fez Cobra board and uses the example programm of GHI at the Wifi Class

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Net.NetworkInformation;
using GHIElectronics.NETMF.Net;
using Microsoft.SPOT.Hardware;
using System.Net;

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(SPI.SPI_module.SPI1, (Cpu.Pin)11, (Cpu.Pin)29);// ChipworkX DevSys
                WiFi.Enable(WiFi.HardwareModule.ZG100M_Compatible,SPI.SPI_module.SPI2, (Cpu.Pin)33, (Cpu.Pin)19);// EMX DevSys
                //WiFi.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)28, (Cpu.Pin)26);// EM 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 != "AP-SSID")
            {
                WiFiSettings.Ssid = "AP-SSID";
                WiFiSettings.PassPhrase = "passphrase";
                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;
                    }
                }
            }
        }

    }
}

The problem is when i use this code I get an error. I have an update version to 4.2(because I also use the STM32F4DiscoveryBoard), the error is that an overload at WiFi.Enable, this is because two pins are not assigned.

When I assigned this pins and fill in the correct SSID and password(also the encryption is good), I start the programm, there will no linked make I get only the error:
WiFi link is not available yet! Wrong AP settings?
Still waiting.

Also debuggin with MFdeploy I see no other comments.

Please help


#2

You need the same wifi module we use.


#3

What Gus is saying is that the GHI WiFi code is explicitly for the GHI provided WiFi module, and won’t support your WiFi board and can’t be made to support it (by you). You’d need to look at other options - either move to the GHI wifi module or write your own driver.


#4

Okay thanks for your reply.

I thought that the MRF24WB0MA was compatible with the ZG2100 module.


#5

Riiiight, I guess that’s a really old / ancient GHI module; I suspect that both Gus and I were talking about one of these http://ghielectronics.com/catalog/product/378

I can’t even remember seeing that module (here’s one reference I found http://www.watterott.com/en/FEZ-WiFi-Expansion ) so I can’t comment on what SDK had support for it, but I reckon it’d be back in 4.0 or earlier days, not the current 4.2 SDK…


#6

Okay, thanks!

I will look for a version of 4.0. In 4.2 I see you can choose for the ZG2100M module, but this don’t seem to work.