hi guys, my problem is this: for my project, I'm using arduino wifi shield, he loaded the sketch wifi web server. I have run the ping to the ip and I recepciona this data, but does not execute the requests that I'm sending from my tablet, which is Android OS 4.0.3, here I leave the sketch used for this purpose
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "wiz610wi"; // your network SSID (name)
char pass[] = ""; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
int PIN_LED=13;
IPAddress ip(192,168,0,101);
String readString=String(30);
String state=String(3);
int status = WL_IDLE_STATUS;
WiFiServer server(80);
void setup() {
// start serial port:
Serial.begin(9600);
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
pinMode(PIN_LED,OUTPUT);
digitalWrite(PIN_LED,LOW);
state="OFF";
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
else {
server.begin();
Serial.print("Connected to wifi. My address:");
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);
}
// wait 10 seconds for connection:
delay(10000);
}
server.begin();
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
int LED = readString.indexOf("LED=");
if(readString.substring(LED,LED+5)=="LED=T")
{
digitalWrite(PIN_LED,false);
state="OFF";
} else if (readString.substring(LED,LED+5)=="LED=F")
{
digitalWrite(PIN_LED,true);
state="ON";
}
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("
");
client.print("Estado del LED: ");
client.print(state);
client.print("
");
client.println("<input type=submit value=ON style=width:200px;height:75px onClick=location.href='./?LED=F\'>"); //Button
client.println("<input type=submit value=OFF style=width:200px;height:75px onClick=location.href='./?LED=T\'>"); //Button
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
Thank you very much for the help given
tesis.ino (3.63 KB)