1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-27 21:16:50 +03:00

Resolved issue #3359 (#6969)

* Resolved issue #3359

Made severing connections optional as per the patch
in the issue.
Also fixed a minor spacing issue.

* Renamed sever to close and added information to readme

Also my editor automatically removed some odd whitespace at the
end of a few lines.
This commit is contained in:
Tim Stableford 2020-02-23 00:30:17 +00:00 committed by GitHub
parent bea64dfa69
commit 16319da63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

5
doc/ota_updates/readme.rst Normal file → Executable file
View File

@ -510,6 +510,11 @@ HTTP Server
``ESPhttpUpdate`` class can check for updates and download a binary file from HTTP web server. It is possible to download updates from every IP or domain address on the network or Internet.
Note that by default this class closes all other connections except the one used by the update, this is because the update method blocks. This means that if there's another application receiving data then TCP packets will build up in the buffer leading to out of memory errors causing the OTA update to fail. There's also a limited number of receive buffers available and all may be used up by other applications.
There are some cases where you know that you won't be receiving any data but would still like to send progress updates.
It's possible to disable the default behaviour (and keep connections open) by calling closeConnectionsOnUpdate(false).
Requirements
~~~~~~~~~~~~

2
libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp Normal file → Executable file
View File

@ -345,8 +345,10 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
WiFiClient * tcp = http.getStreamPtr();
if (_closeConnectionsOnUpdate) {
WiFiUDP::stopAll();
WiFiClient::stopAllExcept(tcp);
}
delay(100);

6
libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h Normal file → Executable file
View File

@ -87,6 +87,11 @@ public:
_followRedirects = follow;
}
void closeConnectionsOnUpdate(bool sever)
{
_closeConnectionsOnUpdate = sever;
}
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
{
_ledPin = ledPin;
@ -152,6 +157,7 @@ protected:
}
int _lastError;
bool _rebootOnUpdate = true;
bool _closeConnectionsOnUpdate = true;
private:
int _httpClientTimeout;
bool _followRedirects;