From 4fd4d73602cbadaa62d8c36373d6f4bb5dde0137 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 12 Feb 2021 13:19:50 +0100 Subject: [PATCH] Add ESP8266 OTA upload fallback to .gz --- tasmota/support_tasmota.ino | 9 +++++++++ tasmota/tasmota.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 07f776f5c..be533ede8 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1077,6 +1077,15 @@ void Every250mSeconds(void) snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal } #endif // FIRMWARE_MINIMAL +#ifdef ESP8266 + if (ota_retry_counter < OTA_ATTEMPTS / 2) { + if (!strcasecmp_P(TasmotaGlobal.mqtt_data, PSTR(".gz"))) { + ota_retry_counter = 1; + } else { + strcat_P(TasmotaGlobal.mqtt_data, PSTR(".gz")); + } + } +#endif // ESP8266 AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data); WiFiClient OTAclient; ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data)); diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index bc27a7df7..c4daf839b 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -147,7 +147,11 @@ const uint32_t BOOT_LOOP_TIME = 10; // Number of seconds to stop detecti const uint32_t POWER_CYCLE_TIME = 8; // Number of seconds to reset power cycle boot loops const uint16_t SYSLOG_TIMER = 600; // Seconds to restore syslog_level const uint16_t SERIALLOG_TIMER = 600; // Seconds to disable SerialLog +#ifdef ESP8266 +const uint8_t OTA_ATTEMPTS = 10; // Number of times to try fetching the new firmware +#else const uint8_t OTA_ATTEMPTS = 5; // Number of times to try fetching the new firmware +#endif // ESP8266 const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in serial command buffer const uint16_t FLOATSZ = 16; // Max number of characters in float result from dtostrfd (max 32)