mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Add setClientTimeout() to ESP8266HTTPUpdate (#8740)
Shortening up the default hard-coded 8000 ms timeout, will save energy when module can't reach its update server, especially on battery powered projects, and otherwise provide adaptability to the local wlan. The ESPhttpUpdate object is auto-created by #including ESP8266HTTPUpdate. ESP8266HTTPUpdate also provides a constructor with param httpClientTimeout, but to use it required destroying the auto ESPhttpUpdate object, or creating a secondESPhttpUpdate(timeout) object.
This commit is contained in:
parent
3c6db4ed9b
commit
9701d3afb6
@ -23,17 +23,11 @@ ESP8266WiFiMulti WiFiMulti;
|
|||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
// Serial.setDebugOutput(true);
|
// Serial.setDebugOutput(false);
|
||||||
|
|
||||||
Serial.println();
|
|
||||||
Serial.println();
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
for (uint8_t t = 4; t > 0; t--) {
|
ESPhttpUpdate.setClientTimeout(2000); // default was 8000
|
||||||
Serial.printf("[SETUP] WAIT %d...\n", t);
|
|
||||||
Serial.flush();
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFiMulti.addAP(APSSID, APPSK);
|
WiFiMulti.addAP(APSSID, APPSK);
|
||||||
|
@ -130,6 +130,9 @@ public:
|
|||||||
int getLastError(void);
|
int getLastError(void);
|
||||||
String getLastErrorString(void);
|
String getLastErrorString(void);
|
||||||
|
|
||||||
|
void setClientTimeout(int timeout) {
|
||||||
|
_httpClientTimeout = timeout;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
t_httpUpdate_return handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs = false);
|
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);
|
bool runUpdate(Stream& in, uint32_t size, const String& md5, int command = U_FLASH);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user