WIFI RS21 - Is the SDK ready for it?

I’m a bit confused about whether the SDK supports this module yet. Can someone from GHI reply with the status? I have the module but am unable to address it in software without an exception.

Re’s

Glenn

Glenn - there would have been a post with a download link if some new code was available.

+1 on the status update.

WiFi RS21 hardware is already supported with the latest GHI NETMF SDK.
But WiFi RS21 module .NET Gadgeteer library still have some issues and it does not work properly.

The bottom line, you can use the wifi module but you need to use GHI.NETMF.NET.WiFi class directly. Gadgeteer code for WiFi is still not done yet. If you are a NET Micro Framework beginner and this is confusing for you, please wait till we release a new Gadgeteer library.

Joe means this I believe but you should always refer to docs fro latest fixes http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/Index.html

This is how the WiFi should be used.


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

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

namespace RTIP_RedPine_test
{
    public class Program
    {
        static public bool network_is_read = false;
        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
            while (true)
            {
                try
                {
                    //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                    WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                    //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);//ChipworkX DevSys
                }
                catch (WiFi.HardwareException e)
                {

                    if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationTimeout || e.errorCode == WiFi.HardwareException.ErrorCode.FirmwareVersionMismatch)
                    {
                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6

                        WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                        WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys

                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);//ChipworkX DevSys
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);
                    }
                    else if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationFailure)
                    {
                        Debug.Print("Check WiFi module hardware connections and SPI/signals configurations");
                        Thread.Sleep(Timeout.Infinite);
                    }

                }

                if (WiFi.IsEnabled)
                {
                    Debug.Print("Searching for WiFi APs");
                    AccessPointInfo[] ScanResp = WiFi.Scan();
                    if (ScanResp != null)
                    {
                        Debug.Print("Total Available Network are " + ScanResp.Length.ToString());
                        foreach (AccessPointInfo x in ScanResp)
                        {
                            Debug.Print(x.SSID);
                        }
                    }
                    int i = 0;
                    for (i = 0; i < ScanResp.Length; i++)
                    {
                        if (string.Compare(ScanResp[i].SSID, "somenetwork") == 0)
                        {
                            break;
                        }
                    }
                    try
                    {
                        if (i < ScanResp.Length)
                        {
                            Debug.Print("Connecting to " + ScanResp[i].SSID);
                            WiFi.ConnectInfrastructure(ScanResp[i], "password");
                            network_is_read = true;
                        }
                        else
                            Debug.Print("The netwrok you are looking for is not there");
                    }
                    catch
                    {
                        Debug.Print("Faild to connect to the Wireless AP");
                    }

                    if (network_is_read)
                    {
                        Debug.Print("WiFi link is ready!");

                        Debug.Print("Enable DHCP");
                        try
                        {
                            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();

                            // Static IP
                            /*****************************/
                            //netif[0].EnableStaticIP("192.168.1.222", "255.255.255.0", "192.168.1.1");
                            //netif[0].EnableStaticDns(new string[] { "10.1.10.1" });

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


                        }
                        catch (SocketException e)
                        {
                            Debug.Print("DHCP Faild");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }

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

                            if (myIP != null)
                            {
                                Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
                            }
                        }
                        catch (SocketException e)
                        {
                            Debug.Print("Faild to Get the host entry of the FQN from DNS server!");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }
                        Thread.Sleep(3000);
                        Debug.Print("Disconnect WiFi link.");
                        WiFi.Disconnect();
                        Thread.Sleep(5000);

                    }

                    Debug.Print("Disable WiFi interface");
                    WiFi.Disable();
                }
                Thread.Sleep(Timeout.Infinite);
            }

        }

        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            if (e.IsAvailable)
            {
                if (WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was established!");
                }
            }
            else
            {
                if (!WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was dropped or disconnected!");
                    network_is_read = false;
                }
            }
        }

    }
}

Perfect. I understand now. Thanks all for the help and Gus, thanks to the link to the latest fixes doc.

Re’s

Glenn

Added it here http://tinyclr.com/forum/21/4373/

I spent some quality time exploring the wifi module this afternoon.

I can enable the connection.
I can scan and receive a list of available access points.
I can [italic]sporadically[/italic] enable DHCP and retrieve an address.
I can retrieve host address information through DNS (if DHCP goes okay)

I cannot disable the wifi object. It hangs to infinity when called. I’ve really not added/subtracted anything in the sample code provided.

I will continue to plug away.

Disconnect() before. does it still hang?

Yes. I am disconnecting first.

This is weird problem. How can we recreate the problem?

Do you have anything else connected to the FEz Spider except the wifi rs21 module?

I had the display and usb modules. That’s it.

The only other actor is the router. That’s an Apple Airport.

Does it hang ant WiFi.Disable() everytime you run the application?

Connect only the wifi module then try it again.

I’m out of ideas on this.

I’ve tried

Connecting to a different router.

Stripping out everything. My program only utilitzes the WiFi module with debugging for feedback.

The results are the same.

It locks up in the WiFi.Disable method and even a reboot from Visual Studio doesn’t interrupt it. I have to push the reset button a few times before VS can communicate with it.

I know that this might seem obvious. Could you please copy&paste the code you are using?

Notes:

[ulist]I’ve used ‘*’ for network names[/ulist]
[ulist]I tried the WiFi in both the Program.cs file and the WiFiExtract file.[/ulist]
[ulist]I’ve tried it on a couple of routers.[/ulist]

Here is the code:

Program.Generated.CS



//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by the Gadgeteer Designer.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program : Gadgeteer.Program
    {
        // GTM.Module defintions

		public static void Main()
        {
			//Important to initialize the Mainboard first
            Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();			

            Program program = new Program();
			program.InitializeModules();
            program.ProgramStarted();
            program.Run(); // Starts Dispatcher
        }

        private void InitializeModules()
        {   
			// Initialize GTM.Modules and event handlers here.
        }
    }
}


Program.cs


using System.Threading;
using GHIElectronics.NETMF.Net;
using Gadgeteer;
using Microsoft.SPOT;
using GT = Gadgeteer;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp1
{
    public partial class Program
    {

        void ProgramStarted()
        {
            Debug.Print("Program Started");

            WiFiExtract.WifiConnect();
            WiFi.Disable();
            Debug.Print("Done disabling");
        }
    }
}

WiFiExtract.cs


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

namespace GadgeteerApp1
{
    public class WiFiExtract
    {
        static public bool network_is_read = false;

        public static int WifiConnect()
        {
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
            while (true)
            {
                try
                {
                    WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                }
                catch (WiFi.HardwareException e)
                {
 
                    if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationTimeout || e.errorCode == WiFi.HardwareException.ErrorCode.FirmwareVersionMismatch)
                    {
                        WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                        WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                    }
                    else if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationFailure)
                    {
                        Debug.Print("Check WiFi module hardware connections and SPI/signals configurations");
                        Thread.Sleep(Timeout.Infinite);
                    }
 
                }

                if (WiFi.IsEnabled)
                {
                    Debug.Print("Searching for WiFi APs");
                    AccessPointInfo[] ScanResp = WiFi.Scan();
                    if (ScanResp != null)
                    {
                        Debug.Print("Total Available Network are " + ScanResp.Length.ToString());
                        foreach (AccessPointInfo x in ScanResp)
                        {
                            Debug.Print(x.SSID);
                        }
                    }
                    int i = 0;
                    for (i = 0; i < ScanResp.Length; i++)
                    {
                        if (string.Compare(ScanResp[i].SSID, "*******") == 0)
                        {
                            break;
                        }
                    }
                    try
                    {
                        if (i < ScanResp.Length)
                        {
                            Debug.Print("Connecting to " + ScanResp[i].SSID);
                            WiFi.ConnectInfrastructure(ScanResp[i], "******");
                            network_is_read = true;
                        }
                        else
                            Debug.Print("The network you are looking for is not there");
                    }
                    catch
                    {
                        Debug.Print("Faild to connect to the Wireless AP");
                    }
 
                    if (network_is_read)
                    {
                        Debug.Print("WiFi link is ready!");
                        try
                        {
                            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
                            
                            // Static IP
                            /*****************************/
                            //netif[0].EnableStaticIP("192.168.0.8", "255.255.255.0", "192.168.0.1");
                            //netif[0].EnableStaticDns(new string[] { "192.168.0.1" });
                            
                            // Dynamic IP
                            /*****************************/
                            if (!netif[0].IsDhcpEnabled)
                                netif[0].EnableDhcp(); // This function is blocking
                            else
                            {
                                netif[0].RenewDhcpLease(); // This function is blocking
                            }
                            network_is_read = true;
                            Debug.Print("Network settings:");
                            Debug.Print("IP Address: " + netif[0].IPAddress);
                            Debug.Print("Subnet Mask: " + netif[0].SubnetMask);
                            Debug.Print("Default Getway: " + netif[0].GatewayAddress);
                            Debug.Print("DNS Server: " + netif[0].DnsAddresses[0]);
 
 
                        }
                        catch (SocketException e)
                        {
                            Debug.Print("DHCP Failed");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }
 
                        Debug.Print("Test DNS");
                        try
                        {
                            IPHostEntry myIP = Dns.GetHostEntry("www.ghielectronics.com");  //Dns.GetHostEntry("207.58.176.212"); 
 
                            if (myIP != null)
                            {
                                Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
                            }
                        }
                        catch (SocketException e)
                        {
                            Debug.Print("Faild to Get the host entry of the FQN from DNS server!");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }
                        Thread.Sleep(3000);
                        Debug.Print("Disconnect WiFi link.");
                        WiFi.Disconnect();
                        Thread.Sleep(5000);
 
                    }
 
                    Debug.Print("Disable WiFi interface");
                    Debug.Print("IsLinkConnected?: " + WiFi.IsLinkConnected);
                    Debug.Print("Current Hardware Module: " + WiFi.CurrentHardwareModule);
                    Debug.Print("IsEnabled? : " + WiFi.IsEnabled);
                   
                }
                return 0;
            }
        }
 
        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            if (e.IsAvailable)
            {
                if (WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was established!");
                }
            }
            else
            {
                if (!WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was dropped or disconnected!");
                    network_is_read = false;
                }
            }
        }
 
    }
}


Debug Log

Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
Version Number is 4.4.5
WiFi Module’s MAC Address is 0351673116226
Searching for WiFi APs
Total Available Network are 9
[snip]
Connecting to *******
WiFi link is ready!
Network settings:
IP Address: 192.168.0.50
Subnet Mask: 255.255.255.0
WiFi connection was established!
Default Getway: 192.168.0.1
DNS Server: 192.168.0.1
Test DNS
www.ghielectronics.com: 207.58.176.212
Disconnect WiFi link.
WiFi connection was dropped or disconnected!
Disable WiFi interface
IsLinkConnected?: False
Current Hardware Module: 1
IsEnabled? : True

Thank you.

Any update on this?

It’s been a week. Can I get an update on this?

We are trying our best. I think we will be able to provide some update this week.

WiFi is not simple at all. There is a reason on GHI is the only company who offers WiFi on NETMF devices :slight_smile: Still, we need this done urgently and we thank you and everyone for the support.

That’s all I wanted to know, Gus. Thanks for the update.

Regards,

Glenn