From 6fa70bda011419520c1484ab7f861114a827e45a Mon Sep 17 00:00:00 2001 From: Martin Ayotte Date: Sun, 6 Dec 2015 09:42:51 -0500 Subject: [PATCH 1/2] replace delay with while loop in WiFiClient.ino --- libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino index 7ffc78acd..8ed67168a 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino @@ -71,7 +71,13 @@ void loop() { client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); - delay(10); + while (client.available() == 0) { + if (timeout - millis() < 0) { + Serial.println(">>> Client Timeout !"); + client.stop(); + return; + } + } // Read all the lines of the reply from server and print them to Serial while(client.available()){ From e166e85f739758a258567b2f49834b05dd8dbd16 Mon Sep 17 00:00:00 2001 From: Martin Ayotte Date: Sun, 6 Dec 2015 09:47:00 -0500 Subject: [PATCH 2/2] oupps ! I forgot to set the timout value --- libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino index 8ed67168a..eb7c02eff 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino @@ -71,6 +71,7 @@ void loop() { client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); + int timeout = millis() + 5000; while (client.available() == 0) { if (timeout - millis() < 0) { Serial.println(">>> Client Timeout !");