Main Site Documentation

Problem WiFi RS21 module with FEZ Spider: first example


#1

Hi all,

I’m new here and with .NET Gadgeteer kits (Spider and Hydra) so excuse me in advance for simple and/or stupid questions maybe already answered on the forum (but I cannot find them).

I have a FEZ Spider Kit and a WifiRS21 module.

I’m trying to run the first example with the Wifi RS21 module. That’s one.
http://www.tinyclr.com/codeshare/entry/361

Visual Studio says (not exactly because is not in Engilsh):
wifi (the variable) doesn’t existe on this context

I have initializated the wifi module on Program.generated.cs as:
wifi_RS21 = new GTM.GHIElectronics.WiFi_RS21(6);

So first solution in my mind is the name of the variable is wrong with respect to the code on Program.cs. If I change it to be the same, it is ok, but the problem now is that most of the methods of the wifi module (UseDHCP(), NetworkDown…) are not recognised for the wifi module.

Am I missing libraries? I will appreciate any help. Thank you very much.


#2

Hi there fprado, welcome to the forum!

Can you clarify what SDK version you have installed and the firmware version you have on your Spider? Then, also let us know what framework version project you created ? I think that the example you pointed out is a 4.1 framework example, and you probably have a 4.2 SDK/device match.


#3

Hi Bret,

Thank you for your answer. That’s right, I’m running 4.2 SDK. Where can I find examples, code samples and documentation about how to use Wifi module (and after that I want to implement web services and especially DPWS) ?

Thank you very much again.


#4

@ andre.m - Thank you. Now the wifi module is working and connected to internet.

About DPWS, the samples code included in the .NET Micro Framework 4.2 are intented to work with the emulator of MF but this doesn’t work so straightforward with the Gadgeteers because you have to initialize the different network protocols and layers before start with web services.

Is there any code or any help to do this? Thank you very much.


#5

@ fprado - Hi fprado!

My wifi RS21 isn’t working in fez spider too. How is your code? My SDK is 4.2 too.

I found the solution for the “wifi”, but in this solution I use G120 and G120 is inside GHI.Premium.Hardware. In this version I don’t have this GHI.Premium.Hardware, just the GHI.Premium.Net.

Sorry for the question, I’m a newbie.

Thank you!


#6

@ Sheila, don’t you have a thread on your own issue elsewhere? You will find that it’s better not to bomb every thread and just focus on the one thread.

(but as a hint: you need to add a REFERENCE to GHI.Premium.Hardware.G120 )


#7

@ sheila.dada - Hi Sheila. This code works for me (FEZ Spider, RS21, Gadgeteer MF4.2):

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

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GHI.Premium.Net;
using Gadgeteer.Modules.GHIElectronics;

namespace WiFi_RS21Tester
{
    public partial class Program
    {
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            if (!wifi_RS21.Interface.IsOpen)
                wifi_RS21.Interface.Open();

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

            NetworkInterfaceExtension.AssignNetworkingStackTo(wifi_RS21.Interface);

            wifi_RS21.Interface.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler(Interface_WirelessConnectivityChanged);
            wifi_RS21.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);

            //Here you have to write the name (SSID) of your local WLAN AP
            WiFiNetworkInfo[] ScanResp = wifi_RS21.Interface.Scan("SSID_OF_YOUR_NETWORK");

            foreach (WiFiNetworkInfo result in ScanResp)
            {
                Debug.Print("****" + result.SSID + "****");
                Debug.Print("ChannelNumber = " + result.ChannelNumber);
                Debug.Print("networkType = " + result.networkType);
                //Debug.Print("PhysicalAddress = " + result.GetMACAddress(result.PhysicalAddress));
                Debug.Print("RSSI = " + result.RSSI);
                Debug.Print("SecMode = " + result.SecMode);
            }

            if (ScanResp != null && ScanResp.Length > 0)
            {
               // Include the password of your WLAN
                wifi_RS21.Interface.Join(ScanResp[0], "PSWD_OF YOUR_NETWORK");
            }
        }

        void Interface_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            Debug.Print("WirelessConnectivityChanged event!");
            Debug.Print("Connected: " + e.IsConnected);
            Debug.Print("IP Address : " + wifi_RS21.Interface.NetworkInterface.IPAddress);
        }

        void Interface_NetworkAddressChanged(object sender, EventArgs e)
        {
            Debug.Print("NetworkAddressChanged event!");
            Debug.Print("IP Address : " + wifi_RS21.Interface.NetworkInterface.IPAddress);
            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]);
                }

        }

    }
}

#8

@ Brett - Hi Brett, thank you for your comments again.

I have fixed my problem with WiFi but I still want to run a DPWS server in my Spider and the sample code doesn’t help so much. Should I mark this thread like fixed and open a new one?


#9

@ Brett - The name of the forum is “Problem WiFi RS21 module with FEZ Spider: first example”. I read all the topics and I had the same problem that fprado had. He found the solution, so I’ve asked him. Please, read again the name of the forum and fprado saying that he found the solution. People like you that demotivate newbies enjoy the forum.


#10

@ fprado - Thank you! With your code it works! :slight_smile:


#11

I’m sorry you feel that way. That’s certainly not the way I intended the message to come across. I honestly thought that you had already started your own thread and that you were effectively double posting here. In hindsight I could have worded my post differently. Sorry for the misunderstanding.


#12

The example in the documents is based on MF 4.1, why do not update to new SDK and MF4.2?
Many newbies will get confused and get frustrated.


#13

@ Tzu Hsuan That’s my case :blush:

How can I update the samplescode from 4.1 to 4.2 or where can I download the new ones?
And what I am supposed to change in the sample code to make it work with the Gadgeteer and not with the emulator? (change the transport property of the project is not enough) .

Thanks.


#14

http://www.ghielectronics.com/community/forum/topic?id=8889
http://www.ghielectronics.com/community/forum/topic?id=10489

These are two of the most helpful DPWS posts that I’ve seen (and can find again) plus they’re both reasonably recent.