Hello,
I am writing to cath some ideas to make a piece of code from blocking to not-blocking. The code in question is from a hobby project where I am working where there is a esp8266 that wait for an HTTP input from my mobile phone.
The problem I am facing is that, AFAIK, I can't know when the HTTP request ends. This brought me to wait 1000 ms since the request start to make sure that every byte is received.
I am willing to have this as not-blocking because meanwhile I will move some steppers. For now i found as a temporary solution to put the steppers.run();
inside the blocking part
client = server.available();
if (client) // Incoming request
{
while (millis() - start_connection < 1000) // blocking part
{
if (client.available() > 0)
{
request[cnt++] = client.read();
}
steppers.run(); // temporary solution
}
}