From e81af052cb80ffe857a5f130c39b4cc242ee44ee Mon Sep 17 00:00:00 2001 From: Tim Stableford Date: Tue, 31 Dec 2019 13:48:06 +0000 Subject: [PATCH] Resolved issue #3359 Made severing connections optional as per the patch in the issue. Also fixed a minor spacing issue. --- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp | 6 ++++-- libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp mode change 100644 => 100755 libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp old mode 100644 new mode 100755 index 2198a28eb4..62dd50e3db --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp @@ -345,8 +345,10 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String& WiFiClient * tcp = http.getStreamPtr(); - WiFiUDP::stopAll(); - WiFiClient::stopAllExcept(tcp); + if (_severConnectionsOnUpdate) { + WiFiUDP::stopAll(); + WiFiClient::stopAllExcept(tcp); + } delay(100); diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h old mode 100644 new mode 100755 index 62fe280cda..15d7c972ee --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h @@ -87,6 +87,11 @@ class ESP8266HTTPUpdate _followRedirects = follow; } + void severConnectionsOnUpdate(bool sever) + { + _severConnectionsOnUpdate = sever; + } + void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH) { _ledPin = ledPin; @@ -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 _severConnectionsOnUpdate = true; private: int _httpClientTimeout; bool _followRedirects;