So I am trying like crazy to get data to flow from the ethernet - but everything
I try is not working.
I am getting the IP address OK (DHCP or static - it all works).
I am setting up the call-back event handler.
I am sending the request.
But my event handler is never called.
I must be doing something basic wrong here - but I am looking too closely. The attached
file is the simplest code to illustrate what I am trying – and what doesnt work. In the attached
file - I load “www.google.com”. The event handler should be called - and never is.
I have two spider boards - so I am fairly sure the hardware is OK. FW is up to date.
Anyone see where I have gone wrong?
Thanks
s
~
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerAppTest
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
//PulseDebugLED();
Debug.Print("Program Started");
led.GreenBlueSwapped = true;
ethernet.NetworkUp += OnNetworkUp;
ethernet.NetworkDown += OnNetworkDown;
//ethernet.UseDHCP();
ethernet.UseStaticIP("192.168.1.111", "255.255.255.0", "192.168.1.1");
while (true) {
if (ethernet.IsNetworkUp)
{
led.BlinkOnce(GT.Color.Blue);
WebClient.GetFromWeb("http://www.google.com/").ResponseReceived += new HttpRequest.ResponseHandler(request_ResponseReceived);
}
else{
led.BlinkOnce(GT.Color.Red);
}
Thread.Sleep(10000);
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~
void request_ResponseReceived(HttpRequest request, HttpResponse response) {
led.BlinkOnce(GT.Color.White);
}
//////////////////////
void OnNetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
led.BlinkOnce(GT.Color.Purple);
Debug.Print(“Network up.”);
}
void OnNetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("Network dn.");
}
}
}