Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved issue #3359 #6969

Merged
merged 2 commits into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions doc/ota_updates/readme.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ As shown below, the signed hash is appended to the unsigned binary, followed by

.. code:: bash

NORMAL-BINARY <SIGNED HASH> <uint32 LENGTH-OF-SIGNING-DATA-INCLUDING-THIS-32-BITS>
NORMAL-BINARY <SIGNED HASH> <uint32 LENGTH-OF-SIGNING-DATA-INCLUDING-THIS-32-BITS>

Signed Binary Prerequisites
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -200,11 +200,11 @@ The following chapters provide more details and specific methods for OTA updates
Arduino IDE
-----------

Uploading modules wirelessly from Arduino IDE is intended for the following typical scenarios:
Uploading modules wirelessly from Arduino IDE is intended for the following typical scenarios:

- during firmware development as a quicker alternative to loading over a serial port,
- during firmware development as a quicker alternative to loading over a serial port,

- for updating a small number of modules,
- for updating a small number of modules,

- only if modules are accessible on the same network as the computer with the Arduino IDE.

Expand Down Expand Up @@ -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
~~~~~~~~~~~~

Expand Down
6 changes: 4 additions & 2 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&

WiFiClient * tcp = http.getStreamPtr();

WiFiUDP::stopAll();
WiFiClient::stopAllExcept(tcp);
if (_closeConnectionsOnUpdate) {
WiFiUDP::stopAll();
WiFiClient::stopAllExcept(tcp);
}

delay(100);

Expand Down
8 changes: 7 additions & 1 deletion libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class ESP8266HTTPUpdate
_followRedirects = follow;
}

void closeConnectionsOnUpdate(bool sever)
{
_closeConnectionsOnUpdate = sever;
}

void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
{
_ledPin = ledPin;
Expand Down Expand Up @@ -146,12 +151,13 @@ class ESP8266HTTPUpdate
// Set the error and potentially use a CB to notify the application
void _setLastError(int err) {
_lastError = err;
if (_cbError) {
if (_cbError) {
_cbError(err);
}
}
int _lastError;
bool _rebootOnUpdate = true;
bool _closeConnectionsOnUpdate = true;
private:
int _httpClientTimeout;
bool _followRedirects;
Expand Down