ESP.RGBWiFi: Added timeout
This commit is contained in:
parent
c033b60c1b
commit
045f7bcad2
1 changed files with 91 additions and 84 deletions
|
@ -115,11 +115,16 @@ void loop() {
|
|||
WiFiClient client = server.available();
|
||||
if (client) {
|
||||
// Wait until the client sends some data
|
||||
Serial.println("Client connected");
|
||||
while(!client.available()){
|
||||
delay(1);
|
||||
Serial.print("Client connected");
|
||||
unsigned char timeouts = 10;
|
||||
while(!client.available() && timeouts > 0){
|
||||
delay(10);
|
||||
timeouts -= 1;
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
|
||||
if (timeouts > 0) {
|
||||
// Read the first line of the request
|
||||
String req = client.readStringUntil('\r');
|
||||
Serial.println(req);
|
||||
|
@ -202,6 +207,8 @@ void loop() {
|
|||
// Send the response to the client
|
||||
client.print(response);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
client.flush();
|
||||
Serial.println("Disconnecting client");
|
||||
// The client will actually be disconnected
|
||||
|
|
Loading…
Reference in a new issue