NetMF cloud connectivity options

I do most of my dev work with NetMF devices and Windows Azure so I though it would be useful\interesting to explore the different cloud connectivity options.

I’ll start with the simplest possible HTTP based approach, look at how to reduce the device memory footprint, reduce traffic on the wire, secure the data, and take the solution mobile.

Then, as time allows I’ll build clients which use

The initial scenario is a GPS equiped NetMF device reporting position information to an application running in Windows Azure. Rather than reinventing the wheel I have used the NetMF Toolbox NMEA GPS module but have added HDoP reporting.

The samples will run on a Netduino, Netduino Plus or Fez Spider.

For the netduino based examples the BoM is

5 thoughts on “NetMF cloud connectivity options

  1. Do you already successfully connect your fez spider with the windows azure service bus? I have some problems doing this. I have a working sample in the NETMF http sample but the same code running on my spider doesn’t work i get some SSL exceptions.

      • Hey Bryn,

        Thanks for your help I have the same problem with your code I’m thinking the problem is in my wifi module. Is it possible? I had almost the same code as you give me. But just to be sure I put your code in my FezSpider to test this is the result:

        void getServiceBusMessage()
        {
        Debug.Print(“Get SB message”);
        try
        {
        using (HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(@”https://kdgthesis.servicebus.windows.net/robot0/messages/head?timeout=60″))
        {
        request.Method = “GET”;
        request.HttpsAuthentCerts = caCerts;
        request.Headers.Add(“Authorization”, “WRAP access_token=\”” + token + “\””);

        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
        if (response.StatusCode == HttpStatusCode.OK)
        {
        PulseDebugLED();
        }
        Debug.Print(response.StatusCode + ” : ” + response.StatusDescription);
        }
        }
        }
        catch (WebException we)
        {
        Debug.Print(we.Message);
        }
        }

        And these are the Exception Messages:
        There are 2 different exception types, the first time it give me a ssl exception and the second time a socket exception.

        Get SB message
        #### Exception System.Net.Sockets.SocketException – CLR_E_FAIL (1) ####
        #### Message:
        #### Microsoft.SPOT.Net.Security.SslNative::SecureRead [IP: 0000] ####
        #### Microsoft.SPOT.Net.Security.SslStream::Read [IP: 0040] ####
        #### System.Net.InputNetworkStreamWrapper::RefillInternalBuffer [IP: 0038] ####
        #### System.Net.InputNetworkStreamWrapper::Read_HTTP_Line [IP: 004b] ####
        #### System.Net.HttpWebRequest::ParseHTTPResponse [IP: 002e] ####
        #### System.Net.HttpWebRequest::GetResponse [IP: 0035] ####
        #### WCF_Connect_Gadgeteer.Program::getServiceBusMessage [IP: 0041] ####
        #### WCF_Connect_Gadgeteer.Program::timer_Tick [IP: 000e] ####
        #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
        #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
        #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
        #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
        #### Gadgeteer.Program::Run [IP: 0020] ####
        #### SocketException ErrorCode = -1728053248
        #### SocketException ErrorCode = -1728053248
        A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.Security.dll
        #### SocketException ErrorCode = -1728053248
        #### SocketException ErrorCode = -1728053248
        #### Exception System.Net.WebException – 0x00000000 (1) ####
        #### Message:
        #### System.Net.HttpWebRequest::GetResponse [IP: 00c8] ####
        #### WCF_Connect_Gadgeteer.Program::getServiceBusMessage [IP: 0041] ####
        #### WCF_Connect_Gadgeteer.Program::timer_Tick [IP: 000e] ####
        #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
        #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
        #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
        #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
        #### Gadgeteer.Program::Run [IP: 0020] ####
        A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll

        Get SB message
        #### Exception System.Net.Sockets.SocketException – CLR_E_FAIL (1) ####
        #### Message:
        #### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
        #### System.Net.Dns::GetHostEntry [IP: 0008] ####
        #### System.Net.HttpWebRequest::EstablishConnection [IP: 00e1] ####
        #### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
        #### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
        #### WCF_Connect_Gadgeteer.Program::getServiceBusMessage [IP: 0041] ####
        #### WCF_Connect_Gadgeteer.Program::timer_Tick [IP: 000e] ####
        #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
        #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
        #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
        #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
        #### Gadgeteer.Program::Run [IP: 0020] ####
        #### SocketException ErrorCode = 10060
        #### SocketException ErrorCode = 10060
        A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
        #### SocketException ErrorCode = 10060
        #### SocketException ErrorCode = 10060
        #### Exception System.Net.WebException – 0x00000000 (1) ####
        #### Message: host not available
        #### System.Net.HttpWebRequest::EstablishConnection [IP: 00f1] ####
        #### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
        #### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
        #### WCF_Connect_Gadgeteer.Program::getServiceBusMessage [IP: 0041] ####
        #### WCF_Connect_Gadgeteer.Program::timer_Tick [IP: 000e] ####
        #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
        #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
        #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
        #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
        #### Gadgeteer.Program::Run [IP: 0020] ####
        A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
        #### Exception System.Net.WebException – 0x00000000 (1) ####
        #### Message:
        #### System.Net.HttpWebRequest::GetResponse [IP: 00d3] ####
        #### WCF_Connect_Gadgeteer.Program::getServiceBusMessage [IP: 0041] ####
        #### WCF_Connect_Gadgeteer.Program::timer_Tick [IP: 000e] ####
        #### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
        #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
        #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
        #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
        #### Gadgeteer.Program::Run [IP: 0020] ####
        A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll

  2. Bryn,
    I forgot to tell that I also tried to update the SSL Seed with MFDeploy a several times but is it possible to check that I did this on the right way? I open MFDeploy and connect my FezSpider with USB then I just click on Target->Manage Device Keys->Update SSL Seed.
    This is the output of MFDeploy:
    Updating SSL seed…
    Using mainboard GHI Electronics FEZSpider version 1.0
    Update Complete!
    So I guess this is okay?

    Again thanks for your help.

    • Hi Carlos,

      Sounds like the SSL seed update worked.

      Here is another sample application which tries to access your sb endpoint over a Wifi connection. This one also fails with a 401 rather than an SSL error but you should be able to work out what you need to change in your app.

      (https://blog.devmobile.co.nz/?attachment_id=606)

      When I get some spare time later in the week I’ll do a post about getting the Wifi module working with more background.

      Bryn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s