Ciao
nell'esempio di cui parli, WebServer, il
client.read() legge di fatto la richiesta del browser (ovvero la url).
Quindi il modo più semplice per processare richieste che arrivano dal client, è salvare il risultato del client.read() in una stringa, e poi effettuare dei confronti.
Partendo dall'esempio WebServer:
...
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) {
...
lo si può espandere, per esempio, in questo modo
....
//stringa usata per salvare la richiesta http; variabile globale
String httpRequest = "";
...
if (client.available()) {
char c = client.read();
Serial.write(c);
//salviamo la richiesta su una stringa
httpRequest += 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) {
//cerchiamo sulla richiesta eventuali comandi
if (httpRequest.indexOf("led1=on") > -1) {
//accendi il led1
...
}
if (httpRequest.indexOf("led2=on") > -1) {
//accendi il led2
...
}
...
//una volta processata la richiesta, svuotare la stringa
httpRequest = "";
}
...
Chiaramente il codice è da ottimizzare, ma spero ti sia di aiuto.