Question

I'm trying to debug why the event NetworkUp never fires on the WiFi RS21 Gadgeteer module and I've distilled it down to a very simple code listing:

using Microsoft.SPOT;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace NetworkUpTest
{
    public partial class Program
    {  
        void ProgramStarted()
        {
            wifi_RS21.UseDHCP();
            wifi_RS21.NetworkUp += wifi_RS21_NetworkUp;
            wifi_RS21.NetworkDown += wifi_RS21_NetworkDown;
            var scans = wifi_RS21.Interface.Scan("LLOYDREGANS");
            if (scans != null && scans.Length > 0)
            {
                Debug.Print("Joining " + scans[0].SSID);
                wifi_RS21.Interface.Join(scans[0], "**********");
            }
            var giveUpWaitingForTheNetworkUpEvent = new GT.Timer(300000, GT.Timer.BehaviorType.RunOnce);
            giveUpWaitingForTheNetworkUpEvent.Tick += giveUpWaitingForTheNetworkUpEvent_Tick;
            giveUpWaitingForTheNetworkUpEvent.Start();
        }

        void wifi_RS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("NetworkUp");
        }

        void wifi_RS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("NetworkDown");
        }

        void giveUpWaitingForTheNetworkUpEvent_Tick(GT.Timer timer)
        {
            Debug.Print("Give up waiting for the NetworkUp event and try requesting the router homepage");
            var request = HttpHelper.CreateHttpGetRequest("http://192.168.1.1/");
            request.ResponseReceived += request_ResponseReceived;
            request.SendRequest();
        }

        void request_ResponseReceived(HttpRequest sender, HttpResponse response)
        {
            Debug.Print("Response received. response.Text.Length = " + response.Text.Length);
        }
    }
}

Here's the listing from the output window when the program runs (minus the thread exited reports):

Using mainboard GHI Electronics FEZSpider version 1.0
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Joining LLOYDREGANS
NetworkDown
Give up waiting for the NetworkUp event and try requesting the router homepage
Response received. response.Text.Length = 2509

Given that the network is demonstrably up, why is "NetworkDown" the only event that fires from the WiFi RS21 module?

Was it helpful?

Solution

The answer on the GHI forum suggests that the correct events to use are:

Interface.WirelessConnectivityChanged
Interface.NetworkAddressChanged

instead of the exemplar code on GHI's WiFi RS21 Gadgeteer module page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top