- Tue Jan 19, 2016 10:18 am
#39229
Sans titre.jpg
I'm maybe a noob with esp, but not stupid.
So your code is the same as this :
Code: Select all// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
// Match the request
int val;
if (req.indexOf("/gpio/0") != -1)
val = 0;
else if (req.indexOf("/gpio/1") != -1)
val = 1;
else {
Serial.println("invalid request");
client.stop();
return;
}
// Set GPIO2 according to the request
digitalWrite(2, val);
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
s += (val)?"high":"low";
s += "</html>\n";
// Send the response to the client
client.print(s);
delay(1);
Serial.println("Client disonnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
Isn't it?
I don't want to learn c++, i just want a simple page web with two bouton on and off.
So if
"If this still goes over your head you perhaps should start with some C++ - book and come back to the ESP a week or two later." is your last option, thanks your and have a nice day.
ps: i'm a 36 years old guy with some basis on c++
but for me a litle bit far away in the time.
You do not have the required permissions to view the files attached to this post.