Main Site Documentation

WiFi (zeroG)


#1

I got my WiFi module today. Yay! Wait…how, how do I get a list of available networks? How do I connect to a secured network? Anyone? I need a freakin’ easy guide for this… :wall:

UPDATE: OK so I found an example on the MSDN. I also found there doesn’t appear to be a way to get broadcast SSID :frowning: [italic]very[/italic] disappointing. Seems such a basic function. Also if I try and save the configuration like in the sample it just hangs. If I don’t save it I never seem to connect. Every to a router that I put wiiide open with no security at all. Yes I’m sure the SSID is correct. Oh and the IDE still hangs trying to reset the thing after each try. I have to close studio and reopen it every single time.

:wall: :wall: :wall:


#2

Did you follow the example code under the WiFi class in GHElectronics library documentation.

And before all of that , Did you connect and configure the interface correctly. I mean SPI, CS and Interrupt signals?


#3

No you can not list the available networks currently. you have to set it.


#4

The MSDN example I mentioned is exactly the same as yours. In fact I’m pretty sure they copied yours, you guys are mentioned a lot over there for NETMF :wink:

So yes, example followed, cable connected properly. Next?


#5

Wifi.Enable(…)? Did you get the settings here right?


#6

WiFi.Enable(SPI.SPI_module.SPI2, (Cpu.Pin)FEZ_Pin.Digital.IO2, (Cpu.Pin)FEZ_Pin.Interrupt.IO26);

Be careful, pin number one at the cable should at the VCC at the UEXT connector.
There is a small arrow at pin number one.


#7

It’s hooked up exactly as shown. I found that completely restoring the device and loading just your sample works, just when I run the same code under Pyxis it fails horribly.

Obviously there is something different between the two and I’ll try to narrow it down. Pyxis enables the WiFi fairly early in it’s boot process so there isn’t much to go through but I’m wondering if I’m not over burdening the board.

Boot Process:
Load Boot Settings from EWR
Display boot screen (Bitmap only not WPF or Touch enabled)
Activate all available USB devices.
Mount SD card if present.
Select best Disk Drive (SD or USB MassStorage)
Enable WiFi

PE Files Loaded: 9
GHI (Hardware, Hardware.EMX, IO, Net, System, USBHost)
Skewworks (Pyxis2, Pyxis2.GUI, Pyxis2.Kernel)

Total Space Used:
488604bytes
477.15KB
.46MEG


#8

I am not sure what is wrong. But you have to keep in mind that Enabling WiFi and WiFi settings are save in flash (like the IP settings). So you don’t have to enable WiFi every time you boot up the application.
Every time you Enable WiFi the whole networking stack restarts internally.

Another thing, Are you using SPI2? if so you have to make sure you use ChipSlelect signal to avoid and collision with ZeroG SPI traffic.


#9

I have a similar problem. I just received my FEZ Cobra and the ZG100 WiFi extension.
I have hooked up the connector with the red wire running from 3.3V / GND on the FEZ to 3.3V / GND on the WiFi extension.

I am attempting to run the WiFi example but I cannot connect to the network.

I set
WiFi.Enable(SPI.SPI_module.SPI2, (Cpu.Pin)FEZ_Pin.Digital.IO2, (Cpu.Pin)FEZ_Pin.Interrupt.IO26);

and

            WiFiSettings.Ssid = "heldscalla";
            WiFiSettings.Encryption = Wireless80211.EncryptionType.None;
           WiFiSettings.Radio = Wireless80211.RadioType.g;
            Wireless80211.SaveConfiguration(new Wireless80211[] { WiFiSettings }, false);

These are correct for my home router.

Is there a way I can debug whether the connection to the WiFi module itself works? I can’t tell right now if the problem is my WiFi settings or whether my connection to the module is not working.

Thanks much!


#10

Yes You can.

Connect Your FEZ Cobra to MFDeploy. You will see some debugging messages like
Searching…
Authentication…
Disconnecting…

But first, please follow the exact same example in the WiFi class libraries documentation.

Also The cable might deceive you. There is a small arrow at pin number one. Do you see it?


#11

When I connect to MFDeploy I see these messages:

WiFi link is not available yet! Wrong AP settings?
Still waiting.
WiFi link is not available yet! Wrong AP settings?
Still waiting.
WiFi link is not available yet! Wrong AP settings?
Still waiting.

I don’t see the “Searching” or “Authenticating.” Does that mean I do not have an active connection to the WiFi module?

The small arrow on the cable points to the hole attached to the 3.3V pin on the FEZ Cobra and to the hole attached to the 3.3V pin on the wifi module. Do I need to do something to reboot the board over and above what visual studio does during deployment?

I have started from scratch using the WiFi sample that shipped with my GHIElectronics SDK (version 1.0.8 August 9 2010). Please note that this sample did not originally have a using directive for GHIElectronics.NETMF.FEZ, so I have added one. Please find a screen shot attached showing all changes from the original example.


#12

If you don’t see the messages I mentioned then the physical cable connection or the Enble() settings is wrong.
Connect MFDelpoy then reset the board to see all the debuging messages. Ping the device from MFDeploy if you did not see the boot up debugging messages in like 10 seconds.


#13

Thanks for the quick response. I will use MFDeploy and check the board’s debugging messages.
Did the settings in the screen shot I attached look correct to you?

Is there a way to check the WiFi Extension part itself to ensure that it is OK and not somehow damaged? I have taken all appropriate care but would like to have some way to check just in case.


#14

By the way, what does “completely restoring” the device mean? Is that distinct from resetting the device? What exactly do I need to do in MFDeploy to “completely restore” the FEZ Cobra?


#15

The code you posted looks OK.

I think it means to Erase everything and reload everything (tinybooter,firmware). But in your case, it is enough to Erase the application code from MFDeploy and Re-download the config file to get the configuration to the initial state I guess.


#16

dmolnar – Did you finally get your ZeroG wifi to work? If so, what was the trick? I am having the same problems.
Thanks,
Carl


#17

Carl,

There should be no problem. Follow the wifi extension user manual and make sure the you connected the cable in the correct direction. Then use the example code in the libraries documentation and edit enable method to be like this ( as mentioned in the user manual)

WiFi.Enable(SPI.SPI_module.SPI2, (Cpu.Pin)FEZ_Pin.Digital.IO2, (Cpu.Pin)FEZ_Pin.Interrupt.IO26);

#18

Joe,
Thanks for responding so quickly. I have attached the red side of the ribbon cable to the 3.3V / GND side of both boards. In the example code, I’ve modified the SSID, PassPhrase & EncryptionType. I needed to add 2 additional references & 1 additional using inorder to compile, see below code. Lastly, I’ve added your WiFi.Enable line with IO2 & IO26. Unfortunately, it still doesn’t work. Any ideas?
Thanks, Carl


/// Add these libraries to your project's References:
/// 
/// System
/// Microsoft.SPOT.Hardware
/// Microsoft.SPOT.Net
/// GHIElectronics.NETMF.System
/// GHIElectronics.NETMF.Net
/// 
/// FEZCobra_GHIElectronics.NETMF.FEZ     // Added by CarlJ
/// Micorsoft.SPOT.Native                 // Added by CarlJ
/// 
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;           // Added by CarlJ

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(SPI.SPI_module.SPI2, (Cpu.Pin)33, (Cpu.Pin)19);// EMX DevSys                        // Commented-out by CarlJ
                //WiFi.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)28, (Cpu.Pin)26);// EM DevSys
                WiFi.Enable(SPI.SPI_module.SPI2, (Cpu.Pin)FEZ_Pin.Digital.IO2, (Cpu.Pin)FEZ_Pin.Interrupt.IO26);  // Added by CarlJ
            }

            // 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 != "KJB")                                  // Modified by CarlJ
            {
                WiFiSettings.Ssid = "KJB";                                   // Modified by CarlJ
    //            WiFiSettings.PassPhrase = "";                              // Commented-out by CarlJ
                WiFiSettings.Encryption = Wireless80211.EncryptionType.None; // Modified by CarlJ
                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;
                    }
                }
            }
        }

    }
}


#19

Is there an easy to tell if my WiFi module is defective? I’m not sure how to use MF-Deploy to test the WiFi module.
Thanks, Carl


#20

Connect your device through MFDeploy after you deploy this application. you shoud see some messages like “searching… authenticating …etc” in the MFDeploy debugging winddow