From 51fd4a868abc32ae9c8c0a53c5b28fcb72c45849 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sat, 26 Sep 2026 23:19:12 +0200 Subject: [PATCH] OTA: don't abort a download on a momentary connected()==false A forced reinstall aborted at 570 B when the TLS client briefly reported disconnected between records; the retry went through. A drop now only counts after 2 s without data. Co-Authored-By: Claude Opus 5.5 --- src/modules/ota_update.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/ota_update.cpp b/src/modules/ota_update.cpp index 03824da..5fb82c7 100644 --- a/src/modules/ota_update.cpp +++ b/src/modules/ota_update.cpp @@ -315,7 +315,11 @@ static bool writeImage(const manifest_t& m, const esp_partition_t* part) { while (ok && got < m.size) { size_t avail = stream->available(); if (avail == 0) { - if (!http.connected() || millis() - last_rx > STALL_TIMEOUT_MS) { + // connected() can read false for a moment between TLS records, so a + // drop only counts after 2 s of silence (it aborted a download at + // 570 B once, 2026-09-26; the retry went through). + uint32_t idle = millis() - last_rx; + if ((!http.connected() && idle > 2000) || idle > STALL_TIMEOUT_MS) { print("[ota] download stalled at %lu/%lu bytes", (unsigned long)got, (unsigned long)m.size); ok = false; break;