Bonjour,
je travail sur un projet en cours et j'aimerais récupérer la valeur qui s'affiche après Get/ grâce a mon Ethernet Shield.
J'ai vraiment chercher sur tout les sites je ne trouve pas, par exemple je rentre l'adresse "monip/?porte=Ouvert" j'aimerais récupérer "porte=Ouvert" et pas "Get /?porte=Ouvert HTTP/1.1 ..."
donc si quelqu'un peut m'aider ce serais sympa, merci ![]()
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(monip);
EthernetServer server(80);
File webFile;
String HTTP_req;
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
Serial.println("Initialisation de la Carte SD");
if (!SD.begin(4)) {
Serial.println("ERREUR - Initialisation de la Carte SD echouee !");
return;
}
Serial.println("SUCCES - Carte SD initialisee.");
if (!SD.exists("index.htm")) {
Serial.println("ERREUR - Fichier introuvable !");
return;
}
Serial.println("SUCCES - Le fichier a ete trouve !");
}
void loop()
{
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
HTTP_req += c;
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// send web page
webFile = SD.open("index.htm");
if (webFile) {
while(webFile.available()) {
client.write(webFile.read());
}
webFile.close();
}
Serial.print(HTTP_req); // La valeur GET s'affiche ici
HTTP_req = "";
break;
}
if (c == '\n') {
currentLineIsBlank = true;
}
else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
delay(1);
client.stop();
}
}