/*
* Web Server
*
* (Based on Ethernet's WebServer Example)
*
* A simple web server that shows the value of the analog input pins.
*/
#include <SPI.h>
#include <WiFly.h>
#include "Credentials.h"
WiFlyServer server(80);
void setup() {
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
while (1) {
// Hang on failure.
}
}
Serial.begin(9600);
Serial.print("IP: ");
Serial.println(WiFly.ip());
server.begin();
}
void loop() {
WiFlyClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("Hello World!");
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(100);
client.stop();
}
}
This is my simple hello world code im tryng to use with my WiFly. Wifly is associating with netowork and everyhting looks fine but when i make a request to WiFly ip then the green led on it stops flashing but the page on browser wont load. Sometimes when i press refresh the red led beside the green one flashes. Very rare occasions i manage to get the response from WiFly and its showed on browser.
Any ideas what should i check/do?
- Using Arduino UNO
- No other shields
EDIT:
When using SpiUartTerminal scetch then afther pointing my broser to Wifly i get this feedback:
*OPEN*GET / HTTP/1.1
Host: 192.168.69.3
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.11 Safari/537.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
And thats it, no response to the browser.. and if i try to send command through terminal it wont go through also.