I recently asked a question about the juniper WiFi shield, and am now working with wifly from spark fun. I've been using an updated version of their experimental library, and have been attempting to set up a webserver. Unfortunately, when I attempt to connect through a web browser, I get an error saying that the page sent no data. Here's my code:
#include <SPI.h>
#include <WiFly.h>
WiFlyServer s(80);
boolean current_line_is_blank=true;
void setup() {
Serial.begin(9600);
WiFly.begin();
if(!WiFly.join(placeholderssid, placeholderpass,WPA_MODE)) {
Serial.println("Connection Failed.");
} else {
Serial.println("Connection Succesful!");
Serial.println(WiFly.ip());
Serial.println("Receving Client Input...");
s.begin();
}
}
void loop() {
WiFlyClient c = s.available();
if(c) {
Serial.println("Server Ready.");
current_line_is_blank=true;
while(c.connected()) {
Serial.println("Client Connected.");
if(c.available()) {
Serial.println("Client Available for data.");
char tmp = c.read();
Serial.println(tmp);
if(tmp == '\n' && current_line_is_blank) {
Serial.println("Sent OK Response.");
c.println("HTTP/1.1 200 OK");
c.println("Content-Type: text/html");
c.println();
c.print("WiFly Webserver Running!");
c.println("<br />");
break;
}
if (tmp == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (tmp != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
}
delay(2000);
c.stop();
}
I am using Arduino Uno, and the serial monitor looks like this:
Connection Succesful!
10.100.1.173
Receving Client Input...
Is there anything obviously wrong with my code?
EDIT: I now have a new shield, but I'm still working with the same problem. Is it a malfunction in the hardware? I just can't figure this out!