0
votes

I've got an ESP32 acting like an access point, running simple page. I've got 2 text input fields there and a button. First of all I open the page, enter some data and then press the send button and I need to be able to get the two strings from the input fields. This is the code I've got so far, but I only get the data back when I refresh the page which is not what I really want and the format looks like this: "GET /?ssid=Ahoj&password=Prdel&SEND=OFF HTTP/1.1"

String html ="<!DOCTYPE html> \
<html> \
<body> \
<center><h1>Configuration Page</h1></center> \
<form> \
<center><h3>Wi-Fi SSID</h3></center> \
<center><input type=\"text\" name=\"ssid\"></center><br><br> \
<center><h3>Wi-Fi Password</h3></center> \
<center><input type=\"text\" name=\"password\"></center> \
<center><button name=\"SEND\" button style=\"color:green\" value=\"OFF\" type=\"submit\">SEND</button><br><br></center> \
</form> \
</body> \
</html>";

void loop() {
  WiFiClient webclient = server.available();   // Listen for incoming clients

  if (webclient) {
    webclient.print(html);
    Serial.println("New Webclient.");          // print a message out in the serial port
    while (webclient.connected()) {            // loop while the client's connected
      if (webclient.available()) {             // if there's bytes to read from the client,
        Serial.println("Read client data : ");
        Serial.println(webclient.readString());
    }
    webclient.stop();
    Serial.println("Webclient disconnected.");
    Serial.println("");
    }
  }
}
1
why not use the WebServer library?Juraj

1 Answers

0
votes

Solved my problem by using

AsyncTCP.h

ESPAsyncWebServer.h