ESP.RGBWiFi: Added timeout

This commit is contained in:
Nis Wechselberg 2017-02-17 23:31:10 +01:00
parent c033b60c1b
commit 045f7bcad2

View file

@ -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