mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Merge pull request #1160 from martinayotte/master
replace delay() with a while loop in WiFiClient.ino
This commit is contained in:
commit
c4436d8d04
@ -71,7 +71,14 @@ void loop() {
|
|||||||
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
|
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
|
||||||
"Host: " + host + "\r\n" +
|
"Host: " + host + "\r\n" +
|
||||||
"Connection: close\r\n\r\n");
|
"Connection: close\r\n\r\n");
|
||||||
delay(10);
|
int timeout = millis() + 5000;
|
||||||
|
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
|
// Read all the lines of the reply from server and print them to Serial
|
||||||
while(client.available()){
|
while(client.available()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user