From 1f539e6bf3020d2a4069295133e0cd470efb8ca9 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Wed, 25 Aug 2021 10:37:46 -0400 Subject: [PATCH] OTA check working! --- otamanager.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/otamanager.cpp b/otamanager.cpp index d99b917..883c2f9 100644 --- a/otamanager.cpp +++ b/otamanager.cpp @@ -14,41 +14,41 @@ otaManager::otaManager(QWidget *parent) : qDebug() << "Checking for available OTA update ..."; if(global::otaUpdate::downloadOta != true) { string_writeconfig("/opt/ibxd", "ota_update_check\n"); - while(true) { + QTimer * otaCheckTimer = new QTimer(this); + otaCheckTimer->setInterval(100); + connect(otaCheckTimer, &QTimer::timeout, [&]() { if(QFile::exists("/run/can_ota_update") == true) { if(checkconfig("/run/can_ota_update") == true) { - emit canOtaUpdate(true); qDebug() << "OTA update is available!"; - break; + emit canOtaUpdate(true); } else { - emit canOtaUpdate(false); qDebug() << "No OTA update available."; - break; + emit canOtaUpdate(false); } + otaManager::close(); } - } - QThread::msleep(500); - otaManager::close(); + } ); + otaCheckTimer->start(); } else { string_writeconfig("/opt/ibxd", "ota_update_download\n"); - while(true) { + QTimer * otaDownloadTimer = new QTimer(this); + otaDownloadTimer->setInterval(500); + connect(otaDownloadTimer, &QTimer::timeout, [&]() { if(QFile::exists("/run/can_install_ota_update") == true) { if(checkconfig("/run/can_install_ota_update") == true) { emit downloadedOta(true); global::otaUpdate::downloadOta = false; - break; } else { emit downloadedOta(false); global::otaUpdate::downloadOta = false; - break; } + otaManager::close(); } - } - QThread::msleep(500); - otaManager::close(); + } ); + otaDownloadTimer->start(); } } else {