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

NetDuino as pachube's like webserver


  • Please log in to reply
7 replies to this topic

#1 antrea

antrea

    New Member

  • Members
  • Pip
  • 4 posts

Posted 11 October 2011 - 06:41 PM

Hi I have two boards: netduino and a regular arduino 2009 (with ethernet shield). I want to use arduino2009 as a client that send (via internet) data to netduino configured as a pachube's like web server. Netduino will take the data from an http request from arduino2009 and storing it on a csv file. ...but... i dont understand how netduino can take a data from an http request... Do i need to use (in netduino) httpresepone class? How? Can you help me? thanks

Arduino, MODs e DIY: blackstufflabs.com


#2 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 12 October 2011 - 01:14 PM

I am not sure how much data you want to send per request but assuming is it only a small amount, say less than an ethernet packet of around 1500 bytes, then I would use "http get" and add the data to the query string. such as "http://localaddress?...MyDataGoesHere" the data itself would have to be url encoded. You would have to find or make a function to do this. The response wouldn't have to say much just make sure it includes a http response code for success ie. 200. you can pull the data off the query string by calling the request.Uri property and using everything after the = sign. Then you would have to unencode the data. I am sorry I cant give you working code, but it would look something like this: int count = connectionSocket.Receive(bytes); Request request = new Request(bytes); string[] arraySplit = request.Uri.Split('='); string data = UrlUnEncode( arraySplit[1]); //keep everything after the = sign Hope this helps
STEFF Shield High Powered Led Driver shield.

#3 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 12 October 2011 - 01:30 PM

GET or POST are both feasible. Netduino will need to have a Socket listening and accepting sockets, regardless of GET or POST. GET: values will be in the URL POST: values will be after the header

#4 antrea

antrea

    New Member

  • Members
  • Pip
  • 4 posts

Posted 12 October 2011 - 03:20 PM

I am not sure how much data you want to send per request but assuming is it only a small amount, say less than an ethernet packet of around 1500 bytes, then I would use "http get" and add the data to the query string.

such as "http://localaddress?...MyDataGoesHere"

the data itself would have to be url encoded. You would have to find or make a function to do this.

The response wouldn't have to say much just make sure it includes a http response code for success ie. 200.

you can pull the data off the query string by calling the request.Uri property and using everything after the = sign.

Then you would have to unencode the data.

I am sorry I cant give you working code, but it would look something like this:

int count = connectionSocket.Receive(bytes);
Request request = new Request(bytes);
string[] arraySplit = request.Uri.Split('=');
string data = UrlUnEncode( arraySplit[1]); //keep everything after the = sign

Hope this helps


Thanks for your reply...
Its a good idea to make a query string but.... i need to make a good and safe autentication.
I dont want to made a single query string with the username and password (maybe) like: http//localaddress?id=MyID&pass=MyPass&data=MyData...etc etc
Its unsafe...

I want to made something like that:

Client: Hi
Server: Pass?
Client: MyPass
Server: Username?
Client: MyUsername
Server: ok... good... how many data?
Client: 1
Server: Ok, tell me!
Client: 30
Server: closing
Client: Bye :)

With arduino i have used a sketch called "PachubeClient" that works exactly as above.

But... i dont have understand HOW (with which class) I can made the server's reply to an http request (not a query string).

On msdn i have read something about HttpWebRequest and HttpWebResponse for comunications between a client and server...

thanks

a.

Arduino, MODs e DIY: blackstufflabs.com


#5 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 12 October 2011 - 03:33 PM

The methods you are outlining don't differ in safety. Why do you think the second is safer than the first?
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#6 antrea

antrea

    New Member

  • Members
  • Pip
  • 4 posts

Posted 12 October 2011 - 04:00 PM

The methods you are outlining don't differ in safety. Why do you think the second is safer than the first?


I have read something on internet about that.

Do you think that a query string is safer as an http requests authentication?

Its more easy for me to parse a query string because i have some example in my book: http://goo.gl/XhYuG

Arduino, MODs e DIY: blackstufflabs.com


#7 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 12 October 2011 - 04:23 PM

"I have read something on the internet" is a bad base for security considerations. It's true that usually you don't want username in password in the URL, but the reasons for that don't apply in your case. If you want to make this "secure", what you'd need to do is encrypt the stream somehow, I don't know if netduino/arduino do that (.net micro framework in general does have support for ssl streams, i don't know if it's in the netduino plus). Both the query string and the HTTP authentification data are sent in plain text (for plain authentification, which is what you mostly see) in the HTTP request, so that does not make a difference.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#8 antrea

antrea

    New Member

  • Members
  • Pip
  • 4 posts

Posted 12 October 2011 - 04:41 PM

"I have read something on the internet" is a bad base for security considerations.



You're right, thanks for your reply... I will use the query string on my project.

Thanks again

A.

Arduino, MODs e DIY: blackstufflabs.com





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.