Wifi rs21

I just got a Wifi RS21 Module. I cannot get it to work though. I have posted the code im using below as well as the debug output.

Debug.Print("Program Started");

            wifi.UseDHCP();
            WiFi_RS21.WiFiNetworkInfo[] results = wifi.Scan();
            foreach(WiFi_RS21.WiFiNetworkInfo network in results)
            {
                Debug.Print(network.SSID);
                Debug.Print(network.networkType.ToString());
                Debug.Print(network.PhysicalAddress.ToString());
                Debug.Print(network.RSSI.ToString());
                Debug.Print(network.ChannelNumber.ToString());
                Debug.Print(network.networkType.ToString());
            }

            WiFi_RS21.WiFiNetworkInfo MyNet = wifi.Search("wireless");
            wifi.Join(MyNet,"15128"); 
            
            if (wifi.IsNetworkConnected)
            {
                led.TurnGreen();
            }

The Debug output is as follows:

Program Started
wireless
1
System.Byte[]
62
6
1
BigPondB6D1B1
1
System.Byte[]
90
11
1
#### Exception System.Exception - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.RS21Driver::Join [IP: 0032] ####
#### GHIElectronics.NETMF.Net.WiFi::Join [IP: 0082] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RS21::Join [IP: 0008] ####
#### Wireless_test.Program::ProgramStarted [IP: 0096] ####
#### Wireless_test.Program::Main [IP: 0015] ####
#### Exception GHIElectronics.NETMF.Net.WiFi+WiFiException - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.WiFi::Join [IP: 00ce] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RS21::Join [IP: 0008] ####
#### Wireless_test.Program::ProgramStarted [IP: 0096] ####
#### Wireless_test.Program::Main [IP: 0015] ####
A first chance exception of type ‘GHIElectronics.NETMF.Net.WiFi.WiFiException’ occurred in GHIElectronics.NETMF.Net.dll
An unhandled exception of type ‘GHIElectronics.NETMF.Net.WiFi.WiFiException’ occurred in GHIElectronics.NETMF.Net.dll

Does anyone have any ideas?

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

Welcome to the forum.

What brand/type of access point do you have? 

Another user reported something similar when trying to join to a Cisco AP, but when using the same code and a different brand AP, it worked just fine.

ive detailed my network AP details below:

Connection-specific DNS Suffix: home
Description: Realtek RTL8187B Wireless 802.11b/g 54Mbps USB 2.0 Network Adapter
Physical Address: ‎00-22-43-59-02-D6
DHCP Enabled: Yes
IPv4 Address: 192.168.1.5
IPv4 Subnet Mask: 255.255.255.0
Lease Obtained: Tuesday, August 28, 2012 8:47:40 PM
Lease Expires: Saturday, September 01, 2012 7:26:44 PM
IPv4 Default Gateway: 192.168.1.1
IPv4 DHCP Server: 192.168.1.1
IPv4 DNS Server: 192.168.1.1
IPv4 WINS Server:
NetBIOS over Tcpip Enabled: Yes
Link-local IPv6 Address: fe80::a4af:5b72:8ed6:2700%11
IPv6 Default Gateway:
IPv6 DNS Server:

It was worth a try, but Cisco != Realtek

I’m pretty sure that it’s ok, but did you try to put a breakpoint on the join command to ensure that the MyNet has a value?

Also, have you tried to use static network info instead of DHCP?

Yeah I set a break point. MyNet does have a value when the join() method is called. It appears to have all the correct information in it as well. I cant find what the issue could be.

Have you tried using static network info instead of DHCP?

I will try that. Should I put the IP address, gateway and DNS address from my network, the ones I have already posted above or should I create different ones? I know that may sound like a really dumb question but I have no idea. First time with networking.

Each device on your network needs a unique IP address. However, the Subnet mask, Gateway and DNS should be the same as what you listed earlier.

If it were me, I would pick the next one higher (I am assuming that the 192.168.1.5 is from your PC) – so 192.168.1.6

From your PC, open a command window and do “PING 192.168.1.6”. If it comes back with 4 “Request timed out.” then more than likely that address is free on your network. If the response to that command is “Reply from 192…” then that address is use - then pick another address and try again, like 192.168.1.7.

Once you get an unused IP address, use that in RS21 module.

Thanks, Still no joy though. I keep getting the exception message. I cant work out what is going wrong. The Module must be able to communicate with the network because it identify available networks. THere is no delay between the Join() method being called and the excpetion message, to me it appears as if the method contians some bad code, with respect to my particular network anyway, although I havent done anything strange to my network and none of my other devices have any problems joining. If there was some delay if the Method call and and excpetion I would be checking the router and authentication but there is no delay at all so I dont beleive the module is even communicating with the router when the method is called.

bsaunders, hi there. I just saw your AP’s name in your debug and thought - an Aussie ! I’m Sydney based, let me know where you are (or update your profile to show that).

I can’t help on the RS21 side though sorry, I don’t have one.

Actually I do have one line of questions about this. We all know the RS21 is sensitive to power, can you tell us what Fez device you have it on and what power supply you have ?

Hi Bret, Im in Townsville. Im running a FEZ Spider, for power im just using the USBClientDP module. Do you think the module is not getting enough power?

Townsville, ok well no local Fezaholics Anonymous meet-up for us then :wink:

DP module, with or without an external power supply? If without, then you may well be pushing the boundaries of a USB power supply, which is meant to be able to supply only 500mA but often don’t. If you can connect the Fez to a powered hub, or better still run the device with a 1A power supply input into the DP module, that would be better. We explicitly saw a module that was working OK up to the point where it had to join an AP; then it reset and did all kinds of weirdness, and by using a more capable power supply the problem was resolved.

OK I will gove that try. I just got another strange result, while trying to run the example code on GHI website:

void ProgramStarted()
        {
            GT.Timer t = new GT.Timer(10000);
            t.Tick += new GT.Timer.TickEventHandler(t_Tick);
            t.Start();
        }
        void t_Tick(GT.Timer timer)
        {
            timer.Stop();

            // setup events
            //wifi.NetworkDown += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            wifi.NetworkUp += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);

            // to use hold the network to connect to
            WiFi_RS21.WiFiNetworkInfo info = null;

            // use the router's DHCP server to set my network info
            wifi.UseDHCP();

            // look for avaiable networks
            WiFi_RS21.WiFiNetworkInfo[] scanResults = wifi.Scan();

            // go through each network and print out settings in the debug window
            foreach (WiFi_RS21.WiFiNetworkInfo result in scanResults)
            {
                Debug.Print("****" + result.SSID + "****");
                Debug.Print("ChannelNumber = " + result.ChannelNumber);
                Debug.Print("networkType = " + result.networkType);
                //Debug.Print("PhysicalAddress = " + GetMACAddress(result.PhysicalAddress));
                Debug.Print("RSSI = " + result.RSSI);
                Debug.Print("SecMode = " + result.SecMode);
            }

            // locate a specific network
            info = wifi.Search("wireless");
            if (info != null)
            {
                wifi.Join(info, "15128");
                Debug.Print("Network joined");

                // After connecting, go out and get a web page. This can also be used to access web services
                Gadgeteer.Networking.HttpRequest wc = WebClient.GetFromWeb("http://www.tinyclr.com");
                wc.ResponseReceived += new HttpRequest.ResponseHandler(wc_ResponseReceived);
            }
}
            void wc_ResponseReceived(HttpRequest sender, HttpResponse response)
        {
            string text = response.Text;
 
            // now that the information has been returned, disconnect from the network
            wifi.Disconnect();
        }

        void wifi_NetworkUp(GT.Modules.Module.NetworkModule sender, GT.Modules.Module.NetworkModule.NetworkState state)
        {
            if (state == GT.Modules.Module.NetworkModule.NetworkState.Up)
                Debug.Print("Network Up event; state = Up");
            else
                Debug.Print("Network Up event; state = Down");
        }
 }

This time the excpetion was with regard to the timer:

wireless
ChannelNumber = 6
networkType = 1
RSSI = 74
SecMode = 3
Infin8solutions
ChannelNumber = 4
networkType = 1
RSSI = 90
SecMode = 2
#### Exception System.Exception - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.RS21Driver::Join [IP: 0032] ####
#### GHIElectronics.NETMF.Net.WiFi::Join [IP: 0082] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RS21::Join [IP: 0008] ####
#### Wireless_test.Program::t_Tick [IP: 00c5] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001c] ####
#### Wireless_test.Program::Main [IP: 001a] ####
#### Exception GHIElectronics.NETMF.Net.WiFi+WiFiException - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.WiFi::Join [IP: 00ce] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RS21::Join [IP: 0008] ####
#### Wireless_test.Program::t_Tick [IP: 00c5] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001c] ####
#### Wireless_test.Program::Main [IP: 001a] ####
A first chance exception of type ‘GHIElectronics.NETMF.Net.WiFi.WiFiException’ occurred in GHIElectronics.NETMF.Net.dll
Exception performing Timer operation

Catch the exception and check it out. It will show you what the issue it.

Well i tried connecting an external power source to the USBClientDP module, I bought one with 12 V output and up to 2.5A. Still no joy. Same exception.

Joe, How would I catch this exception? Could you paste some example code? I tired cathing “GHIElectronics.NETMF.Net.WiFi.WiFiException” but I keep getting a message saying are you missing a reference. Surely if I have added the module I have also added all the required references to effectly command the module, inculding error handling?

@ BSaunders, use a try() catch() block around the Join() and in the catch block print out the error. Untested code coming:


            // locate a specific network
            info = wifi.Search("wireless");
            if (info != null)
            {
try
{
               wifi.Join(info, "15128");
               debug.print("Joined");
}
catch(exception ex)
{
debug.print("Exception was Error: " + ex.Message);
}

}

THe Debug out was Exception was Error: Exception was thrown: GHIElectronics.NETMF.Net.WiFi+WiFiException. Which isnt much help. That was contained in the Debug output when the exception was unhandled, in hind sight.

I appreciate you assistance on this, I have absolutly no idea what the problem is. Im starting the think in my be an issue on on the FEZ Spider itself. although I dont have any other issues with it so maybe it was orginal thought in that the dll contains some some code that simply isnt working with my setup. Although im not running anything special so I cant work out what the issue could be.

on the debug.print line, put a breakpoint and then check out the ex object (hover over it with the mouse), and see if you can see more detail in it’s details.

Look for an inner exception