From 969b0a2e193e76814b239efba6a1371baf3c75ef Mon Sep 17 00:00:00 2001 From: Eiswolf-BG <37225519+Eiswolf-BG@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:05:21 +0200 Subject: [PATCH] Pause NetTask during OTA update/check to avoid WiFi/TLS contention The background task polls ADS-B, weather, and aircraft details every few seconds on Core 0, sharing the same WiFi radio/TLS stack as the OTA check/download. Suspected cause of repeated OTA failures. Now suspended via NetTask::pause() for the duration of both checkForUpdate() and performUpdate(), resumed immediately after. Co-Authored-By: Claude Sonnet 5 --- src/menu_screen.cpp | 5 +++++ src/net_task.cpp | 8 ++++++++ src/net_task.h | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/menu_screen.cpp b/src/menu_screen.cpp index 78acc89..8c9d54a 100644 --- a/src/menu_screen.cpp +++ b/src/menu_screen.cpp @@ -7,6 +7,7 @@ #include "logbook_files_screen.h" #include "webui_screen.h" #include "ota_update.h" +#include "net_task.h" #include "location_presets_screen.h" #include "airline_filter_screen.h" #include "aircraft_watchlist_screen.h" @@ -541,7 +542,9 @@ namespace { tft.drawString(I18n::t(StringId::OTA_CHECKING), Config::SCREEN_WIDTH / 2, Config::SCREEN_HEIGHT / 2); tft.setTextDatum(TL_DATUM); + NetTask::pause(); OtaUpdate::CheckInfo info = OtaUpdate::checkForUpdate(); + NetTask::resume(); if (info.result == OtaUpdate::CheckResult::Error) { infoScreen(tft, I18n::t(StringId::OTA_CHECK_FAILED), "", TFT_RED, I18n::t(StringId::OK)); @@ -560,7 +563,9 @@ namespace { otaProgressTft = &tft; tft.fillScreen(TFT_BLACK); drawOtaProgress(0); + NetTask::pause(); bool ok = OtaUpdate::performUpdate(info.downloadUrl, drawOtaProgress); + NetTask::resume(); otaProgressTft = nullptr; if (ok) { diff --git a/src/net_task.cpp b/src/net_task.cpp index 88cd7f0..5245ae9 100644 --- a/src/net_task.cpp +++ b/src/net_task.cpp @@ -95,4 +95,12 @@ void begin() { ); } +void pause() { + if (taskHandle) vTaskSuspend(taskHandle); +} + +void resume() { + if (taskHandle) vTaskResume(taskHandle); +} + } \ No newline at end of file diff --git a/src/net_task.h b/src/net_task.h index 009df87..640d65f 100644 --- a/src/net_task.h +++ b/src/net_task.h @@ -7,4 +7,13 @@ namespace NetTask { // Startet den Hintergrund-Task. Muss erst NACH WifiMgr::init() und // LocationManager::init() aufgerufen werden. void begin(); + + // Haelt den Hintergrund-Task an bzw. setzt ihn fort - z.B. waehrend + // eines OTA-Updates, da der ESP32 nur eine WLAN-Funkeinheit/einen + // gemeinsamen Netzwerk-Stack fuer beide Cores hat und gleichzeitige + // Anfragen (ADS-B-Polling im Hintergrund vs. OTA-Download) sich in die + // Quere kommen koennen. Beide sicher mehrfach aufrufbar bzw. ohne + // Wirkung, falls der Task noch nicht gestartet ist. + void pause(); + void resume(); } \ No newline at end of file