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 hosted web server over WiFi


  • Please log in to reply
6 replies to this topic

#1 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 21 October 2010 - 08:36 PM

I'm trying to cobble together the parts & code needed to have the netduino act as a web server over WiFi. My end goal is to allow my robot to be controlled / receive commands from Windows Phone 7 device (which can only make http requests; no sockets here). Just as a note I have the original netduino, not the plus model. I was planning to use an XBee shield for WiFi as it appears to have been used successfully by others in this forum. The final missing piece of the puzzle will be to have the netduino listen for http requests and produce some kind of output (and, optionally, return some response data to the device making the requests). I found some code to host a web server from a previous post here http://forums.netdui...ch__1#entry3685 :


WebServer webServer = new WebServer();    
			while (true)    
			{        
				int requestLength = webServer.WaitForRequest(new RequestReceivedDelegate(RequestReceived));        
				
				if (requestLength > 0)        
				{            //-- Build response --            
					responseStr = "HTTP/1.1 200 OK\nContent-Type: text/html\n\n";            
					responseStr += ProcessRequest(receivedStr);                        
					// IMPORTANT: SendResponse() sends response AND closes the connection, please call only once per request.            
					webServer.SendResponse(responseStr);             
					receivedStr = "";        
				}        
				Thread.Sleep(100);    
			}}


Here I'm assuming / hoping the WebServer class is either part of the .NET Micro Framework or part of the example code from the previous post (I guess I should read that code ;). My question is would this work on the original netduino or do I need to upgrade to the plus - and does the overall solution for communicating wirelessly with WP7 sound like the right direction to go? Thanks!!

#2 pascal06

pascal06

    Advanced Member

  • Members
  • PipPipPip
  • 95 posts
  • LocationFrance

Posted 21 October 2010 - 09:02 PM

I'm trying to cobble together the parts & code needed to have the netduino act as a web server over WiFi. My end goal is to allow my robot to be controlled / receive commands from Windows Phone 7 device (which can only make http requests; no sockets here). Just as a note I have the original netduino, not the plus model. I was planning to use an XBee shield for WiFi as it appears to have been used successfully by others in this forum. The final missing piece of the puzzle will be to have the netduino listen for http requests and produce some kind of output (and, optionally, return some response data to the device making the requests). I found some code to host a web server from a previous post here http://forums.netdui...ch__1#entry3685 :


WebServer webServer = new WebServer();    
			while (true)    
			{        
				int requestLength = webServer.WaitForRequest(new RequestReceivedDelegate(RequestReceived));        
				
				if (requestLength > 0)        
				{            //-- Build response --            
					responseStr = "HTTP/1.1 200 OK\nContent-Type: text/html\n\n";            
					responseStr += ProcessRequest(receivedStr);                        
					// IMPORTANT: SendResponse() sends response AND closes the connection, please call only once per request.            
					webServer.SendResponse(responseStr);             
					receivedStr = "";        
				}        
				Thread.Sleep(100);    
			}}


Here I'm assuming / hoping the WebServer class is either part of the .NET Micro Framework or part of the example code from the previous post (I guess I should read that code ;). My question is would this work on the original netduino or do I need to upgrade to the plus - and does the overall solution for communicating wirelessly with WP7 sound like the right direction to go? Thanks!!


Hello James,

To use a netduino with wireless, you don't need the plus version. But you need a wireless shield. Xbee module doesn't use the same wireless techonlogies than your PC or Mobile. PC and Mobile use a wireless named Wi-Fi, which use 802.11() wireless technology. With this technology, it's possible to use a IPv4 stack over it, and use HTTP protocol. XBee modules use a different wireless technology, 802.15.4. This technology is perfect is case of low power needs. But, the frame size is 128 bytes only, so it's impossible to use IPv4 over it. Some IPv6 stack exists using 6lowPAN.

In conclusion :

- Use XBee on Netduino and another XBee on your PC. And forget Mobile use. This is a point to point communication. Like serial over the air.
- Or use a true Wi-Fi 802.11 shield, but you probably need to write a driver for it

Pascal

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 October 2010 - 10:28 PM

James, You can also buy an Ethernet shield for the Netduino and a WiFi<->Ethernet bridge (Linksys, D-Link, etc.). Another user was asking about using the WiFly shield a bit earlier. We'll look into what it would take to support that as well. Chris

#4 Miha Markic

Miha Markic

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationNova Gorica, Slovenia

Posted 26 October 2010 - 08:33 AM

I had the same idea and perhaps a Wifi support should be high priority. If you want to connect Netduino with a mobile device the only options you have are either bluetooth or Wifi. Since bluetooth range isn't that large I'd use Wifi as well. Although I'd use an Android device, not WP7 :-)

Miha Markic, Microsoft MVP C#
Righthand .net consulting and software development
http://blog.rthand.com/


#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 November 2010 - 10:59 PM

I had the same idea and perhaps a Wifi support should be high priority. If you want to connect Netduino with a mobile device the only options you have are either bluetooth or Wifi. Since bluetooth range isn't that large I'd use Wifi as well.


You can also plug the Netduino into your WiFi access point (or Ethernet switch) using an Ethernet shield (or the built-in networking on the Netduino Plus).

We're working through options on WiFi. It may need to be a community project where a bunch of us contribute code, and it won't be as fast as the native networking on the Netduino Plus, but it should be doable...

Chris

#6 Miha Markic

Miha Markic

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationNova Gorica, Slovenia

Posted 05 December 2010 - 04:30 PM

You can also plug the Netduino into your WiFi access point (or Ethernet switch) using an Ethernet shield (or the built-in networking on the Netduino Plus).

We're working through options on WiFi. It may need to be a community project where a bunch of us contribute code, and it won't be as fast as the native networking on the Netduino Plus, but it should be doable...


I'd contribute at time permits me. Did you have any particular WiFi shield in mind?

Miha Markic, Microsoft MVP C#
Righthand .net consulting and software development
http://blog.rthand.com/


#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 December 2010 - 07:24 PM

I'd contribute at time permits me. Did you have any particular WiFi shield in mind?


Hi Miha,

We're looking at the ZeroG and WiFly modules right now... A WiFly shield already exists, so it makes a lot of sense to support that one first if feasable...

Chris




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.