Hi, I use WiFiEsp library by bportaluri and I edited the serverAP exemple as

Hi, I use WiFiEsp library by bportaluri and I edited the serverAP exemple as this:

WiFiEspClient client = server.available(); // listen for incoming clients if (client) { // if you get a client, Serial.println(“New client”); // print a message out the serial port buf.init(); // initialize the circular buffer while (client.connected()) { // loop while the client’s connected if (client.available()) { // if there’s bytes to read from the client, char c = client.read(); // read a byte, then stringa += c; buf.push©; // push it to the ring buffer if (c == ‘\n’) { String result = getParametro(stringa, “hi=”); if (result.equals(“saluta HTTP/1.1”)) { Serial.println(“Ciao”); } else if (result.equals(“salutaEle HTTP/1.1”)) { Serial.println(“Ciao ele”); } } // you got two newline characters in a row // that’s the end of the HTTP request, so send a response if (buf.endsWith("\r\n\r\n")) { sendHttpResponse(client); break; } } } // give the web browser time to receive the data delay(10); // close the connection client.stop(); Serial.println(“Client disconnected”); }

and it works, when I go to 192.168.1.1/hi=saluta it prints:

[WiFiEsp] Server started on port 80 Server started [WiFiEsp] New client 0 New client Ciao Ciao Ciao Ciao Ciao Ciao Ciao [WiFiEsp] Disconnecting 0 Client disconnected

but when after this I go to 192.168.1.1/hi=salutaEle it prints:

[WiFiEsp] New client 0 New client [WiFiEsp] Disconnecting 0 Client disconnected

So my questions are, if somebody knows:

Why it prints “Ciao” so many times?
Why it does not print the second request? It’s like it disconnect the device, but why?

Once your String result gets set to “saluta” it will stay that way until another string comes along OR the ring buffer wraps around. Try putting code into your if else block to clear the buffer after a match.