Main Site Documentation

Problem WiFi RS21 Module


#1

Yesterday i try to run the WiFi RS21 Module on FEZ Spider.

The connection from FEZ Spider to my local network and to the internet works fine.

But when i try to create a socket and listen on a port , then i can’t accses the port from my workstation.
A ping from my workstation to FEZ-Spider doesn’t works to.

I have already installed the newest firmware and lib’s from January.
I try it with GHI and Gadgeteer functions , but it’s always the same result.

I hope someone can give me a tip.
Best regards Raphael


#2

IP addresses set correctly? Fire wall?


#3

yes IP addresses set correctly , and i deactived the Firewall on my wokstation.


#4

Post your code and i’m sure someone will be able to help.


#5

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;


using Microsoft.SPOT.Net.NetworkInformation;

using System.Net.Sockets;
using System.Net;
using System.Text;



using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace WifiNewTest
{
    public partial class Program
    {

        void ProgramStarted()
        {



            wifi.UseStaticIP("192.168.200.79", "255.255.255.0", "192.168.200.1", new string[] { "192.168.200.1" });

            string myAP = "SRA";
            wifi.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            wifi.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);


            Debug.Print("Searching for: " + myAP);
            WiFi_RS21.WiFiNetworkInfo myBSS = wifi.Search(myAP);

            if (myBSS != null)
            {

                Debug.Print("Connecting to " + myAP);

                wifi.Join(myBSS, "GHI"); // Network with WPA or WPA2 security.

                Debug.Print("Connected");

            }
            else
            {
                Debug.Print(myAP + " Wireless network was not found");

            }



            wifi.DebugPrintEnabled = true;



        }

        void wifi_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {


            Debug.Print("Network is Up");
            Debug.Print("IP Address: " + wifi.NetworkSettings.IPAddress.ToString());
            Debug.Print("Subnet Mask: " + wifi.NetworkSettings.SubnetMask.ToString());
            Debug.Print("Gateway: " + wifi.NetworkSettings.GatewayAddress.ToString());
            Debug.Print("DNS Server: " + wifi.NetworkSettings.DnsAddresses[0].ToString());

            NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();



            Thread socketserver = new Thread(TCPServer);
            socketserver.Start();



        }



        void wifi_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network is Down");
        }






        private void TCPServer()
        {

            IPHostEntry myIP = Dns.GetHostEntry("www.schupmehl.de");

            if (myIP != null)
            {
                Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
            }

            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);


            //   server.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.Linger, new byte[] { 0, 0, 0, 0 });
            //   server.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);

            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 8000);

            server.Bind(localEndPoint);
            server.Listen(1);

            byte[] receive;
            while (true)
            {

                try
                {

                    Debug.Print("wait for Connect");

                    Socket clientSocket = server.Accept();



                    receive = new byte[100];


                    clientSocket.Receive(receive);

                    String receivebuffer = new string(Encoding.UTF8.GetChars(receive));
                    Debug.Print(receivebuffer);


                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }

            }

            
        }



        //
    }
}

Using mainboard GHIElectronics-FEZSpider version 1.0
RS21 WiFi module version Number is 4.4.5
WiFi Module’s MAC Address is 0351672714278
Searching for: SRA
Connecting to SRA
Connected
Network is Down
Network is Up
IP Address: 192.168.200.79
Subnet Mask: 255.255.255.0
Gateway: 192.168.200.1
DNS Server: 192.168.200.1
www.schupmehl.de: 82.165.80.60
wait for Connect

And the problem is , now i can’t connect port 8000 from my workstation.


#6

try removing this:


IPHostEntry myIP = Dns.GetHostEntry("www.schupmehl.de");
 
            if (myIP != null)
            {
                Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
            }


#7

Eric, not sure why the DNS test is in the server either, but I can’t really see that it would be a cause for concern?

in your initial problem statement you said:

[quote]The connection from FEZ Spider to my local network and to the internet works fine.

But when i try to create a socket and listen on a port , then i can’t accses the port from my workstation.
A ping from my workstation to FEZ-Spider doesn’t works to.
[/quote]

Simply put, if you can’t PING to the Fez, then any comms isn’t going to work.

What is your PC’s IP address? Is it on the same address range as the hardcoded address you have defined, and is it connected to the same network and router? Until you can PING the device, you can’t expect any other protocol or communication layer to work. You need to get basic connectivity working before you try to get the socket server working.


#8

Furthermore, if you have a fancy router/access point, some of them have options to keep wireless clients isolated from each other.

For instance my Netgear WNDR3700 wireless router has this as an option, if you enable it none of the wireless clients can communicate with each other, they can only communicate with the internet.

Food for thought :slight_smile:

Cheers,
mark


#9

[quote]IPHostEntry myIP = Dns.GetHostEntry(“www.schupmehl.de”);

        if (myIP != null)
        {
            Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
        }[/quote]

I have only add this lines to check the comunication from FEZ to my router. Another test that i have made was to use webrequest to get one webpage from Internet that works also.

My problem is only the comunication to FEZ-Spider.


#10

@ rschupme: since the DNS test worked. could you please try to ping FEZ spider from any other device on the network?


#11

@ Joe, he already said that fails; Yes, I think that’s the fundamental issue here too, until you can do something simple like PING the Fez device, you aren’t going to get anything else working.


#12

OK now i find the problem.

My router AVM 7390 has a problem with the wifi interface. I take another router (Easybox) and it works.

Thanks for all the help.

Best regards Raphael