Web server e comandi seriali

umhh ok, anche se non dovrei ]:slight_smile:

allora, i caratteri di fine connessione sono 2: \n\r
tu invece disconnetti all'arrivo di \n\n, e quindi ti perdi il post. il codice diventa:

#include <Ethernet.h>

byte mac[] = { 0x37, 0xA8, 0xD5, 0x00, 0x00, 0x53 };
byte ip[] = { 192, 168, 1, 145 };

Server server(80);

void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
}

void loop()
{
  Client client = server.available();
  if (client) {
    // an http request ends with \n\r so:
    boolean nWasLastCar = false;

    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);
        // if we've have a \n followed by a \r the request has ended
        if (c == '\r' && nWasLastCar) {
          // send a standard http response header
          client.println("HTTP/1.0 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html><head><title>Prova ethernet</title>");
          client.println("</head><body>");
          client.println("<form name=\"input\" method=\"POST\">");
          client.println("Testo di input: <input type=\"text\" name=\"variabile\" />");
          client.println("<input type=\"submit\" value=\"Invia\" />");
          client.println("</form></body></html> ");
          break;
        }
        if (c != '\n') {
          nWasLastCar = true;
        }else{
          nWasLastCar = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}