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:
@@ -7,6 +7,7 @@
|
|||||||
#include "logbook_files_screen.h"
|
#include "logbook_files_screen.h"
|
||||||
#include "webui_screen.h"
|
#include "webui_screen.h"
|
||||||
#include "ota_update.h"
|
#include "ota_update.h"
|
||||||
|
#include "net_task.h"
|
||||||
#include "location_presets_screen.h"
|
#include "location_presets_screen.h"
|
||||||
#include "airline_filter_screen.h"
|
#include "airline_filter_screen.h"
|
||||||
#include "aircraft_watchlist_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.drawString(I18n::t(StringId::OTA_CHECKING), Config::SCREEN_WIDTH / 2, Config::SCREEN_HEIGHT / 2);
|
||||||
tft.setTextDatum(TL_DATUM);
|
tft.setTextDatum(TL_DATUM);
|
||||||
|
|
||||||
|
NetTask::pause();
|
||||||
OtaUpdate::CheckInfo info = OtaUpdate::checkForUpdate();
|
OtaUpdate::CheckInfo info = OtaUpdate::checkForUpdate();
|
||||||
|
NetTask::resume();
|
||||||
|
|
||||||
if (info.result == OtaUpdate::CheckResult::Error) {
|
if (info.result == OtaUpdate::CheckResult::Error) {
|
||||||
infoScreen(tft, I18n::t(StringId::OTA_CHECK_FAILED), "", TFT_RED, I18n::t(StringId::OK));
|
infoScreen(tft, I18n::t(StringId::OTA_CHECK_FAILED), "", TFT_RED, I18n::t(StringId::OK));
|
||||||
@@ -560,7 +563,9 @@ namespace {
|
|||||||
otaProgressTft = &tft;
|
otaProgressTft = &tft;
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
drawOtaProgress(0);
|
drawOtaProgress(0);
|
||||||
|
NetTask::pause();
|
||||||
bool ok = OtaUpdate::performUpdate(info.downloadUrl, drawOtaProgress);
|
bool ok = OtaUpdate::performUpdate(info.downloadUrl, drawOtaProgress);
|
||||||
|
NetTask::resume();
|
||||||
otaProgressTft = nullptr;
|
otaProgressTft = nullptr;
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|||||||
@@ -95,4 +95,12 @@ void begin() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pause() {
|
||||||
|
if (taskHandle) vTaskSuspend(taskHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resume() {
|
||||||
|
if (taskHandle) vTaskResume(taskHandle);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,13 @@ namespace NetTask {
|
|||||||
// Startet den Hintergrund-Task. Muss erst NACH WifiMgr::init() und
|
// Startet den Hintergrund-Task. Muss erst NACH WifiMgr::init() und
|
||||||
// LocationManager::init() aufgerufen werden.
|
// LocationManager::init() aufgerufen werden.
|
||||||
void begin();
|
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();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user