Page 1 of 1

How do I respond to an HTTP request with a WiFly board?

Posted: Sat Jan 22, 2011 7:33 pm
by rgelb
I am able to read an HTTP request and now I want to respond to it. From what I understand, after sending back a response (e.g. HTTP headers and an HTML page), I am supposed to close the TCP connection.

Do I drop into command mode, manually close the connection and then back to data mode?
Or is there a better way of doing it.

Re: How do I respond to an HTTP request with a WiFly board?

Posted: Wed Feb 02, 2011 12:00 pm
by chrisjp
You may have figured out a solution already, but a great was to control opening and closing connections without dropping into command mode is to use the optional GPIO modes.

GPIO-6 used to represent the connection status.

GPIO-5 is used to toggle the connection open and closed.

See the user guide section 10.5.2.

Code: Select all

<2.20> set ip host <addr>	// set the IP address of the remote host 
<2.20> set ip remote <port> // set the IP port of the remote host 
<2.20> set sys iofunc 0x60	// set alternate function for GPIO-5 and GPIO-6 
<2. 20> save 
<2. 20> reboot	// the module must be rebooted for the alternate settings to take effect
"On the remote host run your application or other software that opens and listens on the <port>.
Connect GPIO-5 to your embedded processor or other control signal. When GPIO-5 is driven high a connection will be attempted. When drive low the connection will be closed. Be sure to not to drive the GPIO with more that 3.3 VDC or permanent damage to the module will occur."

Re: How do I respond to an HTTP request with a WiFly board?

Posted: Mon Feb 07, 2011 11:23 pm
by follower
rgelb wrote:Do I drop into command mode, manually close the connection and then back to data mode?
Or is there a better way of doing it.
Is this connected to an Arduino or some other system?

--Philip;

Re: How do I respond to an HTTP request with a WiFly board?

Posted: Mon Feb 07, 2011 11:26 pm
by follower
chrisjp wrote:GPIO-6 used to represent the connection status.
Interesting, I hadn't noticed that functionality previously. Have you used this with a bare WiFly module (as opposed to the Arduino Shield)? I'm curious if this only works for the "HTTP" functionality built into the module or if it also works for manually opened connections.

--Philip;

Re: How do I respond to an HTTP request with a WiFly board?

Posted: Mon Feb 07, 2011 11:51 pm
by rgelb
follower wrote:Is this connected to an Arduino or some other system?;
I actually got it working. It's not connected to Arduino. It's connected to the Robot Kit from tinyclr.com and is running on the .NET Micro Framework. Here is the video of the final product.

http://www.youtube.com/watch?v=KMI4oVpQ6So