Skip to content

Commit

Permalink
add http client configurable timeout usefull when download is slow on…
Browse files Browse the repository at this point in the history
… server side (esp8266#4705)

* add http client configurable timeout usefull when download is slow from server side

* member init outside constructor body.

* removed this.
  • Loading branch information
marian-craciunescu authored and devyte committed May 4, 2018
1 parent 76a14b1 commit bd87970
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libraries/ESP8266httpUpdate/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP8266httpUpdate
version=1.1
version=1.2
author=Markus Sattler
maintainer=Markus Sattler
sentence=Http Update for ESP8266
Expand Down
8 changes: 7 additions & 1 deletion libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ extern "C" uint32_t _SPIFFS_start;
extern "C" uint32_t _SPIFFS_end;

ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
: _httpClientTimeout(8000)
{
}

ESP8266HTTPUpdate::ESP8266HTTPUpdate(int httpClientTimeout)
: _httpClientTimeout(httpClientTimeout)
{
}

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

// use HTTP/1.0 for update since the update handler not support any transfer Encoding
http.useHTTP10(true);
http.setTimeout(8000);
http.setTimeout(_httpClientTimeout);
http.setUserAgent(F("ESP8266-http-Update"));
http.addHeader(F("x-ESP8266-STA-MAC"), WiFi.macAddress());
http.addHeader(F("x-ESP8266-AP-MAC"), WiFi.softAPmacAddress());
Expand Down
3 changes: 3 additions & 0 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ESP8266HTTPUpdate
{
public:
ESP8266HTTPUpdate(void);
ESP8266HTTPUpdate(int httpClientTimeout);
~ESP8266HTTPUpdate(void);

void rebootOnUpdate(bool reboot)
Expand Down Expand Up @@ -103,6 +104,8 @@ class ESP8266HTTPUpdate

int _lastError;
bool _rebootOnUpdate = true;
private:
int _httpClientTimeout;
};

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
Expand Down

0 comments on commit bd87970

Please sign in to comment.