diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 04e0fdcd9..565dd3379 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2590,7 +2590,7 @@ uint8_t BUploadInit(void) { return 0; } -void BUploadWriteBuffer(uint8_t *buf, size_t size) { +uint32_t BUploadWriteBuffer(uint8_t *buf, size_t size) { if (0 == BUpload.spi_sector_cursor) { // Starting a new sector write so we need to erase it first ESP.flashEraseSector(BUpload.spi_sector_counter); } @@ -2600,7 +2600,11 @@ void BUploadWriteBuffer(uint8_t *buf, size_t size) { if (2 == BUpload.spi_sector_cursor) { // The web upload sends 2048 bytes at a time so keep track of the cursor position to reset it for the next flash sector erase BUpload.spi_sector_cursor = 0; BUpload.spi_sector_counter++; + if (BUpload.spi_sector_counter > (SPIFFS_END -2)) { + return 9; // File too large - Not enough free space + } } + return 0; } #endif // USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE @@ -2918,7 +2922,8 @@ void HandleUploadLoop(void) #ifdef SHELLY_FW_UPGRADE else if (UPL_SHD == Web.upload_file_type) { // Write a block - BUploadWriteBuffer(upload.buf, upload.currentSize); + Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize); + if (Web.upload_error != 0) { return; } } #endif // SHELLY_FW_UPGRADE #ifdef USE_TASMOTA_CLIENT diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 0ab518473..de2d5b2f5 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -17,7 +17,11 @@ along with this program. If not, see . */ -#define XDRV_02 2 +#define XDRV_02 2 + +#ifndef MQTT_WIFI_CLIENT_TIMEOUT +#define MQTT_WIFI_CLIENT_TIMEOUT 200 // Wifi TCP connection timeout (default is 5000 mSec) +#endif // #define DEBUG_DUMP_TLS // allow dumping of TLS Flash keys @@ -635,7 +639,7 @@ void MqttReconnect(void) Response_P(S_LWT_OFFLINE); if (MqttClient.connected()) { MqttClient.disconnect(); } - EspClient.setTimeout(200); + EspClient.setTimeout(MQTT_WIFI_CLIENT_TIMEOUT); #ifdef USE_MQTT_TLS if (Mqtt.mqtt_tls) { tlsClient->stop();