Main Site Documentation

FEZ Spider : WIFI_RS21 dose not work with MF 4.2 on VS 2010, Pls ! (SOLVED)


#1

Hi,
After reading several problem topics about Wifi RS21 module and trying all solutions proposed on these topics, i cannot solve my problem for connecting Wifi RS21 module on my home network. I post here my code and exception errors raising when deploying on FEZSpider. Note that all releases for GHI SDK & Gadgeteer Core, etc… have been installed and updated. Pls help me ! and give me a solution, I’m really frustrating !! :frowning:

EMX Version : 4.2.10.1
Using mainboard GHI Electronics FEZSpider version 1.0
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5

Error :

Exception System.Exception - 0x00000000 (1)

#### Message: 
#### GHI.Premium.Net.RS9110Helper::Join [IP: 003b] ####
#### GHI.Premium.Net.WiFiRS9110::Join [IP: 008b] ####
#### Technosvalg.Program::WiFiRS21Connect [IP: 00d4] ####
#### Technosvalg.Program::ReadConfiguration [IP: 00d1] ####
#### Technosvalg.Program::ProgramStarted [IP: 000a] ####
#### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
#### Message: 
#### GHI.Premium.Net.WiFiRS9110::Join [IP: 00e7] ####
#### Technosvalg.Program::WiFiRS21Connect [IP: 00d4] ####
#### Technosvalg.Program::ReadConfiguration [IP: 00d1] ####
#### Technosvalg.Program::ProgramStarted [IP: 000a] ####

A first chance exception of type ‘GHI.Premium.Net.NetworkInterfaceExtensionException’ occurred in GHI.Premium.Net.dll
Exception was thrown: GHI.Premium.Net.NetworkInterfaceExtensionException


 private void WiFiRS21Connect()
        {
            if (!wifi_RS21.Interface.IsOpen)
                wifi_RS21.Interface.Open();

            if (!wifi_RS21.Interface.NetworkInterface.IsDhcpEnabled)
                wifi_RS21.Interface.NetworkInterface.EnableDhcp();
            else
                wifi_RS21.Interface.NetworkInterface.RenewDhcpLease();

            NetworkInterfaceExtension.AssignNetworkingStackTo(wifi_RS21.Interface);

            wifi_RS21.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);
            wifi_RS21.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            wifi_RS21.Interface.NetworkAddressChanged       +=
                                new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(wifiRS21_NetworkAddressChanged);
            wifi_RS21.Interface.WirelessConnectivityChanged +=
                                new WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_RS21_WirelessConnectivityChanged);

            try
            {                
                Debug.Print("Scan for wireless networks");
                WiFiNetworkInfo[] scanResult = wifi_RS21.Interface.Scan(AppSettings.NetworkSSID);

                if (scanResult != null && scanResult.Length > 0)
                {
                    wifi_RS21.Interface.Join(scanResult[0], AppSettings.NetworkPassphrase);
                    Debug.Print("Connected");
                }
                else
                {
                    Debug.Print(" Wireless network was not found : " + AppSettings.NetworkSSID);
                }
                Debug.Print("IP Address: " + wifi_RS21.Interface.NetworkInterface.IPAddress);
                Debug.Print("Subnet Mask: " + wifi_RS21.Interface.NetworkInterface.SubnetMask);
                Debug.Print("Default Getway: " + wifi_RS21.Interface.NetworkInterface.GatewayAddress);
                for (int j = 0; j < wifi_RS21.Interface.NetworkInterface.DnsAddresses.Length; j++)
                {
                    Debug.Print("DNS Server: " + wifi_RS21.Interface.NetworkInterface.DnsAddresses[j]);
                }
            }
            catch (Exception e)
            {
                Debug.Print(e.Message);
            }
 }

void wifi_RS21_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            if (wifi_RS21.Interface != null && !wifi_RS21.Interface.IsActivated 
                && !wifi_RS21.Interface.IsOpen && !wifi_RS21.Interface.IsLinkConnected && !e.IsConnected)
            {
                Debug.Print("WiFi is Disconnected! -> event: Wirless Connectivity Changed.");
            }
            else
            {
                Debug.Print("Wireless Connectivity Changed event.");
                WiFiNetworkInfo infoNetwork = e.NetworkInformation;
                if (infoNetwork != null)
                {
                    string str1 = WiFiNetworkInfoToString(infoNetwork);
                    Debug.Print(str1);
                }
                Debug.Print("Is DhCp enabled: " + wifi_RS21.Interface.NetworkInterface.IsDhcpEnabled);
                Debug.Print("Is DynamicDnsEnabled enabled: " + wifi_RS21.Interface.NetworkInterface.IsDynamicDnsEnabled);
                Debug.Print("NetworkInterfaceType " + wifi_RS21.Interface.NetworkInterface.NetworkInterfaceType);
                Debug.Print("Network settings:");
                Debug.Print("IP Address: " + wifi_RS21.Interface.NetworkInterface.IPAddress);
                Debug.Print("Subnet Mask: " + wifi_RS21.Interface.NetworkInterface.SubnetMask);
                Debug.Print("Default Getway: " + wifi_RS21.Interface.NetworkInterface.GatewayAddress);
                Debug.Print("Number of DNS servers:" + wifi_RS21.Interface.NetworkInterface.DnsAddresses.Length);
                for (int i = 0; i < wifi_RS21.Interface.NetworkInterface.DnsAddresses.Length; i++)
                    Debug.Print("DNS Server " + i.ToString() + ":" + wifi_RS21.Interface.NetworkInterface.DnsAddresses[i]);
                Debug.Print("------------------------------------------------------");
            }
        }

        void wifiRS21_NetworkAddressChanged(object sender, EventArgs e)
        {
            if (wifi_RS21.Interface != null && !wifi_RS21.Interface.IsLinkConnected)
            {
                Debug.Print("wifi.Interface is Disconnected! -> event: Network Address Changed.");
            }
            else
            {
                Debug.Print("Network Address Changed event.");
                Debug.Print("Is DhCp enabled: " + wifi_RS21.Interface.NetworkInterface.IsDhcpEnabled);
                Debug.Print("Is DynamicDnsEnabled enabled: " + wifi_RS21.Interface.NetworkInterface.IsDynamicDnsEnabled);
                Debug.Print("NetworkInterfaceType " + wifi_RS21.Interface.NetworkInterface.NetworkInterfaceType);
                Debug.Print("Network settings:");
                Debug.Print("IP Address: " + wifi_RS21.Interface.NetworkInterface.IPAddress);
                Debug.Print("Subnet Mask: " + wifi_RS21.Interface.NetworkInterface.SubnetMask);
                Debug.Print("Default Getway: " + wifi_RS21.Interface.NetworkInterface.GatewayAddress);
                Debug.Print("Number of DNS servers:" + wifi_RS21.Interface.NetworkInterface.DnsAddresses.Length);
                for (int i = 0; i < wifi_RS21.Interface.NetworkInterface.DnsAddresses.Length; i++)
                    Debug.Print("DNS Server " + i.ToString() + ":" + wifi_RS21.Interface.NetworkInterface.DnsAddresses[i]);
                Debug.Print("------------------------------------------------------");
            }
        }

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


        private void wifi_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            // Network is available.
            AppSettings.IPAddress = wifi_RS21.NetworkSettings.IPAddress;

            // Synchronize the Clock with a Reference Server on the Internet.
            WindowsManager.StartupScreen.SetStatusMessage("Synchronizing time...");
            TimeManager timeManager = TimeManager.Instance;
            timeManager.TimeSynchronized += new EventHandler(timeManager_TimeSynchronized);
            timeManager.Synchronize(AppSettings.TimeZoneOffset);
     }



#2

@ hoavinh - When you debug your code, do you find your SSID in WiFiNetworkInfo[] scanResult? Are you sure AppSettings.NetworkPassphrase is filled properly?


#3

Thanks for your first response.
Yes, There are the first informations I need to verify when debuging.
That are all correct.


#4

Some one can test my code and give me a confirmation ? pls !


#5

We are currently investigating this issue and should have our results posted shortly.


#6

After testing it, using the code you provided above, I received this in my Output Window of Visual Studio.

Network Address Changed event.
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.1.105
Subnet Mask: 255.255.255.0
Default Getway: 192.168.1.9
Number of DNS servers:2
DNS Server 0:75.75.75.75
DNS Server 1:75.75.76.76
------------------------------------------------------

You could try placing a break-point on the line that actually calls join in your WiFiRS21Connect method, and ensure that the requested network you are scanning for is actually at index 0. It is also possible that your router has a dual broadcast mode of operation, and the compatible network is on another index.


#7

Thank you very much, I will look back my home network setting.


#8

or better still, use the test code that GHI published (the DHCP testing code) as it handles the correct selection of the network based on actual network name matching requested network.


#9

Thanks Brett I Will Check and test it in this week-end,
and come back if I would need your help again. Thanks again members in this forum for your helps


#10

I’ve find the solution. My problem comes from wireless router security. My solution is to change my wireless router to WPA(AES/CCMP) instead of WPA(TKIP/AES).
My Router is FreeBox V6, Im from PARIS.

Hope my help for everyone.

Best regards,