Download Print this page

DFRobot FireBeetle ESP32-E Manual page 26

Advertisement

Serial.println(myIP);
server.begin();
Serial.println("Server started");
}
void loop() {
WiFiClient client = server.available();
if (client) {
Serial.println("New Client.");
String currentLine = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c == '\n') {
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
// the content of the HTTP response follows the header:
client.print("Click <a href=\"/H\">here</a> to turn ON the LED.<br>");
client.print("Click <a href=\"/L\">here</a> to turn OFF the LED.<br>");
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
} else {
// if you got a newline, then clear currentLine:
currentLine = "";
}
// listen for incoming clients
// if you get a client,
// print a message out the serial port
// make a String to hold incoming data from the client
// loop while the client's connected
// if there's bytes to read from the client,
// read a byte, then
// print it out the serial monitor
// if the byte is a newline character

Advertisement

loading
Need help?

Need help?

Do you have a question about the FireBeetle ESP32-E and is the answer not in the manual?

Questions and answers

Related Products for DFRobot FireBeetle ESP32-E

This manual is also suitable for:

Dfr0654