1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

Changed timeout logic

Changed timeout to unsigned long. Using addition with millis() is not recommended. 
Source: http://www.gammon.com.au/millis
This commit is contained in:
Hemal Chevli
2016-04-05 10:53:15 +05:30
parent 5dd6acc4c2
commit 81859c5df6

View File

@ -71,9 +71,9 @@ 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");
int timeout = millis() + 5000; unsigned long timeout = millis();
while (client.available() == 0) { while (client.available() == 0) {
if (timeout - millis() < 0) { if (millis() - timeout < 5000) {
Serial.println(">>> Client Timeout !"); Serial.println(">>> Client Timeout !");
client.stop(); client.stop();
return; return;