From 80c659c3bde0128bc108c5b4c608d49d01255969 Mon Sep 17 00:00:00 2001 From: DarioGHub <49622669+DarioGHub@users.noreply.github.com> Date: Sat, 3 Dec 2022 18:07:51 -0600 Subject: [PATCH 1/6] defined new method setClientTimeout Alternative to destroying auto created object ESPhttpUpdate, then recreating it with the constructor that supported a timeout --- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp index df709bdd2f..ef1d252c45 100755 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp @@ -61,6 +61,15 @@ void ESP8266HTTPUpdate::setAuthorization(const String &auth) _auth = auth; } +/** + * set the Timeout for the http request + * @param httpClientTimeout const int& millis + */ +void ESP8266HTTPUpdate::setClientTimeout(const int &httpClientTimeout) +{ + _httpClientTimeout = httpClientTimeout; +} + HTTPUpdateResult ESP8266HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion) { HTTPClient http; From 65aa0c343ba53fceaf4d3a23d786546ed671030d Mon Sep 17 00:00:00 2001 From: DarioGHub <49622669+DarioGHub@users.noreply.github.com> Date: Sat, 3 Dec 2022 18:10:19 -0600 Subject: [PATCH 2/6] declared new member setClientTimeout() --- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h index 6c6b140f39..4e0c5aa3b5 100755 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h @@ -130,6 +130,8 @@ class ESP8266HTTPUpdate int getLastError(void); String getLastErrorString(void); + void setClientTimeout(const int &); + protected: t_httpUpdate_return handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs = false); bool runUpdate(Stream& in, uint32_t size, const String& md5, int command = U_FLASH); From e31ce329362c6a1e67f11aa21ef9d2cde511968c Mon Sep 17 00:00:00 2001 From: DarioGHub <49622669+DarioGHub@users.noreply.github.com> Date: Sat, 3 Dec 2022 18:19:50 -0600 Subject: [PATCH 3/6] added call to new method setClientTimeout changed commented setDebugOutput to false to reflect the core 3 behaviour of wifi debug output by default. Removed a couple of newlines, and the 4 second wait block from setup. --- .../examples/httpUpdate/httpUpdate.ino | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino b/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino index f245d2363d..c64d38533a 100644 --- a/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino +++ b/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino @@ -23,17 +23,11 @@ ESP8266WiFiMulti WiFiMulti; void setup() { Serial.begin(115200); - // Serial.setDebugOutput(true); + // Serial.setDebugOutput(false); - Serial.println(); - Serial.println(); Serial.println(); - for (uint8_t t = 4; t > 0; t--) { - Serial.printf("[SETUP] WAIT %d...\n", t); - Serial.flush(); - delay(1000); - } + ESPhttpUpdate.setClientTimeout(2000); // default was 8000 WiFi.mode(WIFI_STA); WiFiMulti.addAP(APSSID, APPSK); From 6ef16f391d48eb82f9c6336984b6220c655cedb4 Mon Sep 17 00:00:00 2001 From: DarioGHub <49622669+DarioGHub@users.noreply.github.com> Date: Sun, 4 Dec 2022 11:53:57 -0600 Subject: [PATCH 4/6] removed a few spaces to pass clang format test --- libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino b/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino index c64d38533a..b9da7f8cb4 100644 --- a/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino +++ b/libraries/ESP8266httpUpdate/examples/httpUpdate/httpUpdate.ino @@ -27,7 +27,7 @@ void setup() { Serial.println(); - ESPhttpUpdate.setClientTimeout(2000); // default was 8000 + ESPhttpUpdate.setClientTimeout(2000); // default was 8000 WiFi.mode(WIFI_STA); WiFiMulti.addAP(APSSID, APPSK); From 5acecaf5ea51b2b9b39794394848cdaff443e1a6 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Tue, 6 Dec 2022 12:41:38 +0300 Subject: [PATCH 5/6] Update libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h --- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h index 4e0c5aa3b5..4d741cdaa5 100755 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h @@ -130,8 +130,9 @@ class ESP8266HTTPUpdate int getLastError(void); String getLastErrorString(void); - void setClientTimeout(const int &); - + void setClientTimeout(int timeout) { + _httpClientTimeout = timeout; + } protected: t_httpUpdate_return handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs = false); bool runUpdate(Stream& in, uint32_t size, const String& md5, int command = U_FLASH); From 1f6ec6d484c346d1b1bedfd0d1df22a0ee50c8a5 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Tue, 6 Dec 2022 12:41:44 +0300 Subject: [PATCH 6/6] Update libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp --- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp index ef1d252c45..df709bdd2f 100755 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp @@ -61,15 +61,6 @@ void ESP8266HTTPUpdate::setAuthorization(const String &auth) _auth = auth; } -/** - * set the Timeout for the http request - * @param httpClientTimeout const int& millis - */ -void ESP8266HTTPUpdate::setClientTimeout(const int &httpClientTimeout) -{ - _httpClientTimeout = httpClientTimeout; -} - HTTPUpdateResult ESP8266HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion) { HTTPClient http;