sito web con arduino html pagine separate

ciao vi chiedo un secondo un aiuto perché è da 6 ore che provo a compilare un programma cambiano la minima cosa ma arriva a un punto che non funziona mai niente, ormai tra poco finisco il numero di volte che posso programmare arduino :slightly_frowning_face: (scherzo)

come avevo già detto sto provando il modulo ethernet e volevo dividere le varie "paginette" dividendo l'html in funzioni, del tipo vado a recuperare l'url richiesta con :

String richiesta = (char *)Ethernet::buffer + pos;
che restituisce:
GET /pagina_richiesta HTTP/1.1
Host: 10.25.30.28
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4

poi lo divido in 2, la parte quella del nome del file richiesto che si chiama file e in get che è tutto quello che si trova dopo il (?) e se non è presente non restituisce nessun get.
fatto questo pensavo di andare a dire se la richiesta è = a "pagina1" invio html della pagina 1 e via così....

il problema è che fino a che le comparazioni non superano un tot numero, oppure il nome della stessa pagina e abbastanza corto allora va bene altrimenti sembra quasi scomparire la ricerca del'url perché mi restituisce sempre campo vuoto.

vi passo 2 codici il primo funziona mentre il secondo (che è relativamente uguale) restituisce sempre la prima pagina.
se sapete aiutarmi vi faccio il santino del vostro avatar nel mio portafoglio perché ormai ho buttato all'aria un intera giornata sbattendo sempre sullo stesso muro
Codice che va:

//static byte myip[] = {10,25,30,28};
#include <EtherCard.h>

static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
static byte myip[] = {10,25,30,28};
byte Ethernet::buffer[700];
String buffer_seriale;

void setup () {
 
  Serial.begin(57600);
  Serial.println("WebLed Demo");
 
  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
    Serial.println( "Failed to access Ethernet controller");
 else
   Serial.println("Ethernet controller initialized");
 
 if (!ether.staticSetup(myip))
   Serial.println("Failed to set IP address");
}
  
void loop() {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
 
  if(pos) {
    String richiesta = (char *)Ethernet::buffer + pos;
    
    String url;
    int url_l = richiesta.indexOf("/")+1;
    int url_h = richiesta.indexOf("/",url_l)-5;
    url = richiesta.substring(url_l,url_h);
    
    String file;
    String get;
    int get_i = url.indexOf("?");
    if(get_i != -1){
      file = url.substring(0, get_i);
      get  = url.substring(get_i+1, -1);
    } else{
      file = url;
      get = "";
    }
  
    Serial.println("--------------------------------");
    Serial.print("nuova richiesta url(");
    Serial.print(url);
    Serial.print(") file(");
    Serial.print(file);
    Serial.print(") get(");
    Serial.print(get);
    Serial.println(")");
    
    BufferFiller bfill = ether.tcpOffset();
    String html;
    if(file == ""){
      html = file_0();
    } else if(file == "1"){
      html = file_1();
    } else if(file == "2"){
      html = file_2();
    }
    
    char *Shtml = &html[0];
    bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
      "Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
      "pagina richiesta -> \n $S"
      ), Shtml);
    ether.httpServerReply(bfill.position());
  }
}

/*====================================================================*/
/*====================================================================*/
/*====================================================================*/
String file_0(){
 String html = "ciao";
  return html;
}

String file_1(){
  String html = "1";
  return html;
}

String file_2(){
  String html = "2";
  return html;
}

codice che non va :

//static byte myip[] = {10,25,30,28};
#include <EtherCard.h>

static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
static byte myip[] = {10,25,30,28};
byte Ethernet::buffer[700];
String buffer_seriale;

void setup () {
 
  Serial.begin(57600);
  Serial.println("WebLed Demo");
 
  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
    Serial.println( "Failed to access Ethernet controller");
 else
   Serial.println("Ethernet controller initialized");
 
 if (!ether.staticSetup(myip))
   Serial.println("Failed to set IP address");
}
  
void loop() {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
 
  if(pos) {
    String richiesta = (char *)Ethernet::buffer + pos;
    
    String url;
    int url_l = richiesta.indexOf("/")+1;
    int url_h = richiesta.indexOf("/",url_l)-5;
    url = richiesta.substring(url_l,url_h);
    
    String file;
    String get;
    int get_i = url.indexOf("?");
    if(get_i != -1){
      file = url.substring(0, get_i);
      get  = url.substring(get_i+1, -1);
    } else{
      file = url;
      get = "";
    }
  
    Serial.println("--------------------------------");
    Serial.print("nuova richiesta url(");
    Serial.print(url);
    Serial.print(") file(");
    Serial.print(file);
    Serial.print(") get(");
    Serial.print(get);
    Serial.println(")");
    
    BufferFiller bfill = ether.tcpOffset();
    String html;
    if(file == ""){
      html = file_0();
    } else if(file == "file_1"){
      html = file_1();
    } else if(file == "file_2"){
      html = file_2();
    } else{
      html = file_404();
    }
    
    char *Shtml = &html[0];
    bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
      "Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
      "pagina richiesta -> \n $S"
      ), Shtml);
    ether.httpServerReply(bfill.position());
  }
}

/*====================================================================*/
/*====================================================================*/
/*====================================================================*/
String file_0(){
 String html = "ciaooooooo";
  return html;
}

String file_1(){
  String html = "pagina1";
  return html;
}

String file_2(){
  String html = "pagina2";
  return html;
}

String file_404(){
  String html = "errore 404, la pagina richiesta non e presente nel server";
  return html;
}

non hai più risposto a questo treadh da seriale a ethernet con arduino - #6 by ilmandorlone - Software - Arduino Forum