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 <noreply@anthropic.com>
This commit is contained in:
Eiswolf-BG
2026-08-13 22:05:21 +02:00
parent a5b0e5404a
commit 969b0a2e19
3 changed files with 22 additions and 0 deletions

View File

@@ -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) {

View File

@@ -95,4 +95,12 @@ void begin() {
);
}
void pause() {
if (taskHandle) vTaskSuspend(taskHandle);
}
void resume() {
if (taskHandle) vTaskResume(taskHandle);
}
}

View File

@@ -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();
}