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

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.

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.

<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 .

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."

rgelb:
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;

chrisjp:
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;

follower:
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