From c791da9fbff983e8ad3d015fedb75877fde5fbda Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Fri, 20 Aug 2021 17:12:51 -0400 Subject: [PATCH] OTA improvements --- otamanager.cpp | 71 ++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/otamanager.cpp b/otamanager.cpp index 8bbca94..ffa7505 100644 --- a/otamanager.cpp +++ b/otamanager.cpp @@ -3,47 +3,56 @@ #include "functions.h" #include +#include otaManager::otaManager(QWidget *parent) : QWidget(parent), ui(new Ui::otaManager) { ui->setupUi(this); - if(global::otaUpdate::downloadOta != true) { - string_writeconfig("/opt/ibxd", "ota_update_check\n"); - QTimer *otaCheckTimer = new QTimer(); - 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); - otaManager::close(); - } - else { - emit canOtaUpdate(false); - otaManager::close(); + if(QFile::exists("/mnt/onboard/onboard/.inkbox/SKIP_OTACHECK") == false) { + qDebug() << "Checking for available OTA update ..."; + if(global::otaUpdate::downloadOta != true) { + string_writeconfig("/opt/ibxd", "ota_update_check\n"); + while(true) { + if(QFile::exists("/run/can_ota_update") == true) { + if(checkconfig("/run/can_ota_update") == true) { + emit canOtaUpdate(true); + qDebug() << "OTA update is available!"; + break; + } + else { + emit canOtaUpdate(false); + qDebug() << "No OTA update available."; + break; + } } } - } ); + QThread::msleep(500); + otaManager::close(); + } + else { + string_writeconfig("/opt/ibxd", "ota_update_download\n"); + while(true) { + 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; + } + } + } + QThread::msleep(500); + otaManager::close(); + } } else { - string_writeconfig("/opt/ibxd", "ota_update_download\n"); - QTimer *otaDownloadTimer = new QTimer(); - 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; - otaManager::close(); - } - else { - emit downloadedOta(false); - global::otaUpdate::downloadOta = false; - otaManager::close(); - } - } - } ); + qDebug() << "Skip OTA update check!"; } }