Getting Started with the Internet of Things by Cuno Pfister - Page 2 - Visual Studio - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Getting Started with the Internet of Things by Cuno Pfister


  • Please log in to reply
37 replies to this topic

#21 PhilG

PhilG

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationMaine

Posted 21 September 2011 - 03:26 PM

I am not sure what MFDeploy is used for but I launched it. I selected Device USB and it displays Netduino_NetduinoPlus. Then Target/Connect and sometimes it hangs. If it runs it displays "Connected 192.168.5.100". Since my router is using DHCP it probably wont connect to that address. How do I get the Netduino into accepting a DHCP address? If I select Configuration/Network it hangs. I have tried another WebServer from Zimmers that exhibits the same problem.

#22 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 21 September 2011 - 07:56 PM

Suggestions?

What firmware version do you use? I have heard of similar problems with DHCP, which could be solved using static IP addresses. Apparently should be corrected with newer (beta) firmware releases.

Best regards

Cuno

#23 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 September 2011 - 08:11 PM

Hi PhilG, If you set the IP address to "0.0.0.0" in MFDeploy and _then_ enable DHCP does that result in a dynamic address being allocated to your Netduino Plus? Also, there are bugfixes for DHCP in v4.1.1 beta and v4.2 RC1 firmware. The upcoming v4.2 RC3 firmware will have additional networking bugfixes, although I'm not sure if any are DHCP related. Chris

#24 PhilG

PhilG

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationMaine

Posted 21 September 2011 - 08:12 PM

News Flash. It's working. I rand MFDeploy then selected Target / Connect and Configuration / Network and it hung. I then unplugged the USB cable and reconnected got an error message (Device has old or unsupported configuration). I then clicked Target Disconnect and Connect and then Configuration / Network and the network panel appeared. If I waited too long it hung again. Then I unchecked the DHCP box and set the Gateway to the address of my router (192.168.1.1) then and I set the Static IP address to something other than 192.168.5.100 ( I randomly chose 192.1.68.1.60) and it worked! What's up with that? Why should the static address have anything to do with DHCP? (No it didn't work until I changed the static address). Phil

#25 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 September 2011 - 08:17 PM

Hi Phil, Although DHCP is a standard, it seems like different routers conform to slightly different variations. The lwIP networking stack should work with most or all of them. Microsoft has also applied some patches to make it work with corporate Microsoft DHCP servers. If there are ones that it doesn't work with, a WireShark trace would be awesome...so we can track down the issue and contribute improvements back to NETMF/lwIP. Chris

#26 willgeorge

willgeorge

    Member

  • Members
  • PipPip
  • 25 posts

Posted 22 September 2011 - 06:05 PM

Hi,
is /has anyone else worked through this book yet?
Although it is quite well written with good examples, and I have learnt quite a bit about the netduino plus, I can't get past chapter 10 with the 'Hello Web' example. Is there any one else out there with the same issue?

Yours Simon M.


Not sure if this will help but my basic code that worked.
Also: Try this link at Pachube about projects that worked... http://community.pachube.com/forum/58

Simple code that worked for me

using System;
using System.Threading;
using Gsiot.PachubeClient;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

//
//// This code worked 9/14/11
//
public class HelloPachube
{
    public static void Main()
    {
        const string apiKey = "YOUR KEY here";
        const string feedId = "YOUR feed number here";
        const int samplingPeriod = 60000;   // 60 seconds

        const double maxVoltage = 3.3;
        const int maxAdcValue = 1023;

        var voltagePort = new AnalogInput(Pins.GPIO_PIN_A1);
        var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
        var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

        while (true)
        {
            WaitUntilNextPeriod(samplingPeriod);
            int rawValue = voltagePort.Read();
            double value = (rawValue * maxVoltage) / maxAdcValue;
            string sample = "voltage," + " Test only";
            //string sample = "Data," + value.ToString("f");
            Debug.Print("new message: " + sample);
            PachubeClient.Send(apiKey, feedId, sample);
        }
    }

    static void WaitUntilNextPeriod(int period)
    {
        long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
        var offset = (int)(now % period);
        int delay = period - offset;
        Debug.Print("sleep for " + delay + " ms\r\n");
        Thread.Sleep(delay);
    }
}


// I included the Gsiot.PachubeClient into my project. I used a Netduino Plus and ethernet.
// As a note I did have a initial problem because I was getting an error from Pachube 404 or maybe 402..
// I was using the 'typed name' of my feedID when I should have been using the NUMBER!
Good luck!

#27 Tim Drew

Tim Drew

    New Member

  • Members
  • Pip
  • 5 posts

Posted 24 September 2011 - 04:13 AM

Phil, I ran mine using the free relay site, yaler, and it worked pretty much first go. I have not tried a local only version just yet. If I get a chance I will try it out and let you know. I have a similar networking setup at home myself. I did give the NetDuino Plus a static ip address outside the dynamic range my router can use.
Did you have any issues running the "C:\Program Files\Microsoft .NET Micro Framework\v4.1\Tools\
MFDeploy.exe" tool ?


Phil, where are you at with this problem now ?
Were you able to get the MFDeploy tool to connect and successfully ping your NetDuinoPlus?
I have reserved an ip address on my router and permanently reserved it for the mac address of my NetDuinoPlus. It is inside the DHCP range set in my router.

Using the HelloWebHTML example from the book with only the RelayDomain and RelaySecretKey lines commented out I can connect directly to the static address I assigned. In this case http://192.168.1.101/hello.html and I get the expected web page containing only the "Hello Web at 01/01/2009 00:02:04 " message.

Let me know if you are still having issues or not.

#28 mike_swede

mike_swede

    New Member

  • Validating
  • Pip
  • 1 posts

Posted 12 December 2011 - 01:25 PM

Also had problems with "HelloWeb" and "HelloWebHtml" which took a while to solve. I want to share my solution which actually was a stupid "spelling" error of mine. Both programs worked in my local network, but not when I connected to Yaler. I did not notice that the "<" and ">" also had to be deleted, and just inserted the domain and key strings between them. RelayDomain = "<insert your relay domain here>", RelaySecretKey = "<insert your secret key here>", But when I eventually deleted the "<" and ">" in the beginning and end of the strings... ...it all worked like a charm!!! Thanks for a fun project!

#29 Msbh

Msbh

    New Member

  • Members
  • Pip
  • 8 posts

Posted 25 December 2011 - 07:30 AM

I set all like as you said and as it was in forum . I ran MFdeploy. it ping and tinyclr was on output. but when I run Network it hanged up and I plug out net+ and pluged it again and then its not responding and not detectable . It is not detected by computer not in USB option of MFdeploy not in transport of VS. I reinstall every thing but it is not detected by computer. i cant connect Net+ to computer. :(

#30 Chip Moody

Chip Moody

    New Member

  • Members
  • Pip
  • 2 posts

Posted 03 May 2012 - 04:42 AM

So I've gotten up to the HelloPachube portion of GSIOT, and found that the account/feed setup on Pachube no longer matches the description in the book at all. I tried to make best guesses when setting everything up, but I've apparently not done it correctly - HelloPachube kicks back 403 (forbidden) errors on every attempt to post data. One of the things - and maybe this is the only thing hanging me up - is that while GSIOT talks about finding a "private master API key", I can find no mention of that at all. I tried setting up a "secure sharing" key and using that, but I'm thinking it's not the right tool for the job. Any suggestions? Thanks, - Chip

#31 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 22 May 2012 - 02:13 PM

So I've gotten up to the HelloPachube portion of GSIOT, and found that the account/feed setup on Pachube no longer matches the description in the book at all. I tried to make best guesses when setting everything up, but I've apparently not done it correctly - HelloPachube kicks back 403 (forbidden) errors on every attempt to post data.

One of the things - and maybe this is the only thing hanging me up - is that while GSIOT talks about finding a "private master API key", I can find no mention of that at all. I tried setting up a "secure sharing" key and using that, but I'm thinking it's not the right tool for the job.

Any suggestions?

Thanks,
- Chip

Unfortunately, things keep changing :(

I've tried to use my old GSIoT test feed, and it still works. I then created a completely new account, and created a "secure sharing key" and used that for a new feed. I felt a bit disoriented for a while on the Cosm Web site, but it finally worked:

blog post

If this still does not work, maybe you could try my diagnostic program at http://www.gsiot.inf...ip?t=1309432158
to find out whether you can actually access servers outside of your local network at all.

Cuno

#32 HawkGT

HawkGT

    New Member

  • Members
  • Pip
  • 3 posts

Posted 24 July 2012 - 12:18 AM

Using the HelloWebHTML example from the book with only the RelayDomain and RelaySecretKey lines commented out I can connect directly to the static address I assigned. In this case http://192.168.1.101/hello.html and I get the expected web page containing only the "Hello Web at 01/01/2009 00:02:04 " message.



Thank you so much for that tip! I was just trying the network address (http://192.168.1.101) but omitting the hello.html portion. Somehow I missed that bit from the description given in the book. So thank you for this post; I only wasted one day trying to figure out where I had gone wrong. :rolleyes:

#33 Capt Paul

Capt Paul

    New Member

  • Members
  • Pip
  • 3 posts

Posted 05 February 2013 - 10:55 PM

I am trying to run the HelloWeb example from "Getting Started With The Internet of Things".  

Everything compiles and runs, and I get "Base Uri: http://192.168.1.33//" (I'm running on my local network).

When I try to access the server from Chrome or IE nothing happens and I get debug ouput:

 

 

A first chance exception of type 'System.Exception' occurred in Gsiot.Server.dll
exception in Run.ConsumeRequest:
System.Exception: precondition failed
A first chance exception of type 'System.Exception' occurred in Gsiot.Server.dll
exception in Run.ConsumeRequest:
System.Exception: precondition failed
 
I am running 4.2.2 (but I had the same results with 4.2.1) on a Plus2.
 
Any ideas what might be going wrong?


#34 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 06 February 2013 - 05:59 PM

 
 
 

Any ideas what might be going wrong?

In the current version of Gsiot.Server, there is a bug that prevents you from using it on the local network. It should work with Yaler, though.

 

I'll put together a new version of Gsiot.Server before the end of the month, at http://www.gsiot.info/download/. As a quick fix, you may make the following changes to Gsiot.Server.cs, i.e., comment out the green line:

 
public void
Open()

  {
  Contract.Requires(!IsOpen);

// default configuration for the book - must be removed for use on devices without Ethernet:

StreamListener = new EthernetStreamListener();
  [color=rgb(0,128,0);]// comment out this line StreamFactory = new EthernetStreamFactory();[/color]

 

Note that then Yaler will not work.

 

Does this help?

 

Best regards

 

Cuno



#35 Capt Paul

Capt Paul

    New Member

  • Members
  • Pip
  • 3 posts

Posted 06 February 2013 - 07:12 PM

Thanks Cuno,

The quick fix worked for HelloWeb and VoltageMonitor. I'm now moving on to the rest of the examples. I'm really enjoying your book! I'll look forward to any future updates.

Thanks again,

Paul



#36 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 06 February 2013 - 09:12 PM

Thanks Cuno,

The quick fix worked for HelloWeb and VoltageMonitor. I'm now moving on to the rest of the examples. I'm really enjoying your book! I'll look forward to any future updates.

Thanks again,

Paul

Glad to hear :)



#37 eddyogi

eddyogi

    New Member

  • Members
  • Pip
  • 5 posts

Posted 22 February 2013 - 10:22 PM

 
 
 

In the current version of Gsiot.Server, there is a bug that prevents you from using it on the local network. It should work with Yaler, though.

 

I'll put together a new version of Gsiot.Server before the end of the month, at http://www.gsiot.info/download/. As a quick fix, you may make the following changes to Gsiot.Server.cs, i.e., comment out the green line:

 
public void
Open()

  {
  Contract.Requires(!IsOpen);

// default configuration for the book - must be removed for use on devices without Ethernet:

StreamListener = new EthernetStreamListener();
  [color=rgb(0,128,0);]// comment out this line StreamFactory = new EthernetStreamFactory();[/color]

 

Note that then Yaler will not work.

 

Does this help?

 

Best regards

 

Cuno

 

This fix also worked for me, I had the same exact problem as Capt Paul.

 

I'd like to say I am also enjoying your book, very informative.

 

I'd like to ask a question, is there a way to serve up files from an SD card using GSIOT.server?

 

Regards,

 

Edmond



#38 nlatin

nlatin

    New Member

  • Members
  • Pip
  • 3 posts

Posted 23 December 2013 - 05:55 PM

Cuno or somebody please help..

 

I am using your gsiot library with np2 and i noticed packet fragmentation that slows web page rendering, i used wireshark and

saw max packet size 128 byte. There is no router between.

How to prevent packet fragmentation?

How to change mtu packet size?

 

hi from Croatia..






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.