Page 1 of 1

Using delay with WebServer handleClient

Posted: Sun Jun 30, 2019 5:32 pm
by Emygma
Hello,

I am using this library to run a simple webserver, with the ESP32 as AP
https://github.com/espressif/arduino-es ... Server.ino

Everything works fine, if there's only server.handleClient(); in the loop and nothing else.

But the problem is that i need to run another function in the loop that takes a about 150ms to complete.
So something like this:

Code: Select all

loop()
{
    server.handleClient();
   test();
}

void test()
{
   digitalWrite(13, HIGH);
   delay(5);
   digitalWrite(13, LOW);
   delay(150);
   digitalWrite(13, HIGH);
}

And that causes a problem where when I POST an html form, i get an error page in my browser sometimes with a closed connection message.
Basically, sometimes the page loads and sometimes it does not.

So how can I make the server.handleClient() work properly with that delay?