Skip to content

Commit bd87970

Browse files
marian-craciunescudevyte
authored andcommitted
add http client configurable timeout usefull when download is slow on server side (#4705)
* add http client configurable timeout usefull when download is slow from server side * member init outside constructor body. * removed this.
1 parent 76a14b1 commit bd87970

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

libraries/ESP8266httpUpdate/library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP8266httpUpdate
2-
version=1.1
2+
version=1.2
33
author=Markus Sattler
44
maintainer=Markus Sattler
55
sentence=Http Update for ESP8266

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ extern "C" uint32_t _SPIFFS_start;
3030
extern "C" uint32_t _SPIFFS_end;
3131

3232
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
33+
: _httpClientTimeout(8000)
34+
{
35+
}
36+
37+
ESP8266HTTPUpdate::ESP8266HTTPUpdate(int httpClientTimeout)
38+
: _httpClientTimeout(httpClientTimeout)
3339
{
3440
}
3541

@@ -170,7 +176,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
170176

171177
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
172178
http.useHTTP10(true);
173-
http.setTimeout(8000);
179+
http.setTimeout(_httpClientTimeout);
174180
http.setUserAgent(F("ESP8266-http-Update"));
175181
http.addHeader(F("x-ESP8266-STA-MAC"), WiFi.macAddress());
176182
http.addHeader(F("x-ESP8266-AP-MAC"), WiFi.softAPmacAddress());

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ESP8266HTTPUpdate
6464
{
6565
public:
6666
ESP8266HTTPUpdate(void);
67+
ESP8266HTTPUpdate(int httpClientTimeout);
6768
~ESP8266HTTPUpdate(void);
6869

6970
void rebootOnUpdate(bool reboot)
@@ -103,6 +104,8 @@ class ESP8266HTTPUpdate
103104

104105
int _lastError;
105106
bool _rebootOnUpdate = true;
107+
private:
108+
int _httpClientTimeout;
106109
};
107110

108111
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)

0 commit comments

Comments
 (0)