WiFi RS21 Module

Hello all,
I’m trying to get my WiFi RS21 Module to connect to my router, I’m using the provided example code verbatim (with my network details, obviously) https://www.ghielectronics.com/docs/105/wifi-rs21-module

…and I get the error\output below, I can confirm that it does find my network (and about 10 others :))

ChannelNumber = 7
networkType = 1
PhysicalAddress = 00-30-4F-A7-B0-E7
RSSI = 86
SecMode = 2
The thread '<No Name>' (0x3) has exited with code 0 (0x0).
    #### Exception System.Exception - 0x00000000 (1) ####
    #### Message: 
    #### GHI.Premium.Net.RS9110Helper::Join [IP: 003b] ####
    #### GHI.Premium.Net.WiFiRS9110::Join [IP: 008b] ####
    #### LightTower.Program::t_Tick [IP: 00f2] ####
    #### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
    #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 0020] ####
    #### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
    #### Message: 
    #### GHI.Premium.Net.WiFiRS9110::Join [IP: 00e7] ####
    #### LightTower.Program::t_Tick [IP: 00f2] ####
    #### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
    #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 0020] ####
A first chance exception of type 'GHI.Premium.Net.NetworkInterfaceExtensionException' occurred in GHI.Premium.Net.dll
Exception performing Timer operation
Network Up event; state = Down

I’ve also tried a really cut down version, and it hangs in the same place with the same error (.Join(…))

 wifi_RS21.UseDHCP();
            GHI.Premium.Net.WiFiNetworkInfo info = new GHI.Premium.Net.WiFiNetworkInfo();
            info.SSID = "my_sid";
            info.SecMode = GHI.Premium.Net.SecurityMode.WEP;
            info.networkType = GHI.Premium.Net.NetworkType.AccessPoint;
            wifi_RS21.Interface.Join(info, "network_password");

Thoughts?

From my experience i know that Join sometimes fail when the WiFi signal is weak.
You could try to place the Join in a retry loop and not to give up after the first attempt fail. Try to place your router closer to your WiFi module.

Hey Rob, thanks for responding. The router is about 2 meters away and I have full signal on my phone. By retry, do you mean something like the below?

           for (int i = 0; i < 10; i++)
                {
                    wifi_RS21.Interface.Join(info[0], "pass");
                    Thread.Sleep(1000);
                    Debug.Print("Network joined");

                }

@ origin - Hi, yes of coarse skip the loop if joined well.

Even though your router is close to your WiFi module the RSSI shows 86 which is still a weak signal to me… Are you sure its the signal strength from your router.

While I like the one shot, no scan join, sometimes it can make problems hard to find so try this:


            try
            {
                wi = wifi_RS21.Interface.Scan("SSID");
                if (wi != null)
                {
                    wifi_RS21.Interface.Join(wi[0], "Password");
                    Debug.Print("Network joined");
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

put a breakpoint after the scan so you can see if it found your network, and then you can see if it can join your network. Once you know that works then go back and try the no scan join.

Assuming the 5 bar thing is linear, 86% is 5 bars, but, I figured it out. I turned my phone into a WiFi hotspot and it worked on the first go which didn’t seem to make sense. But it turns out someone in my area has the same SSID as me, it’s weak, but it’s there. I tried changing my SSID back and forth several times to make sure this wasn’t a fluke, but there you have it! -)

I noticed Gus had compiled a list of things to check when your WiFi modules weren’t working in a forum post. Possibly something to add?

Duke, the simple block of code works just well for this case, it now joins the network, by which i mean wifi_RS21.IsNetworkConnected is True but, IsNetworkUp is False. I can see the Fez on my routers device table, but it doesn’t seem to be able to make HTTP requests, what am I likely doing wrong?

@ origin - FYI RRSI is in dBu (decibel) and not a percentage. If interested see Decibel - Wikipedia

Doh! Awesome though, thanks :slight_smile:

So! It is working now using the verbatim code, I was getting Null as a text response from http://www.ghielectronics.com because it was returning a 302 redirect response. Switching that up to another site gives me some nice HTML.

When the wifi_NetworkUp event is triggered, the NetworkState object is GT.Modules.Module.NetworkModule.NetworkState.Down, why would that be? What exactly does the NetworkState mean?