From 874c55f809e4308062635d7e7d4efcfe9e09fdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Tue, 17 May 2022 14:55:05 +0200 Subject: [PATCH] Make NXP update provider independent from the chip module type --- .../backends/nxp/firmwareupdatehandlernxp.cpp | 33 ++++--------------- .../backends/nxp/firmwareupdatehandlernxp.h | 2 -- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.cpp b/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.cpp index 70ce005..0a9bbf1 100644 --- a/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.cpp +++ b/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.cpp @@ -155,20 +155,8 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid return; } - if (!releaseMap.contains("firmware")) { - qCWarning(dcZigbeeController()) << "Update provider configuration available but the release file does not contain available firmware file name" << releaseFileInfo.absoluteFilePath(); - return; - } - - m_availableFirmwareFileName = releaseMap.value("firmware").toString(); - if (m_availableFirmwareFileName.isEmpty()) { - qCWarning(dcZigbeeController()) << "Update provider configuration available but the firmware file path in the release file is empty" << releaseFileInfo.absoluteFilePath(); - return; - } - - QFileInfo firmwareFileInfo(releaseFileInfo.canonicalPath() + QDir::separator() + m_availableFirmwareFileName); - if (!firmwareFileInfo.exists()) { - qCWarning(dcZigbeeController()) << "Update provider configuration available but the update firmware file does not exist" << firmwareFileInfo.absoluteFilePath(); + if (!releaseMap.value("releases").toList().isEmpty()) { + qCWarning(dcZigbeeController()) << "Update provider configuration available but the release file does not contain available releases" << releaseFileInfo.absoluteFilePath(); return; } @@ -177,7 +165,7 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid configuration.endGroup(); - qCDebug(dcZigbeeController()) << "Firmware update provider available:" << firmwareFileInfo.fileName() << "Version:" << m_availableFirmwareVersion << "Initially flashed:" << m_initiallyFlashed; + qCDebug(dcZigbeeController()) << "Firmware update provider available with version:" << m_availableFirmwareVersion << "Initially flashed:" << m_initiallyFlashed; // Set up update process m_updateProcess = new QProcess(this); @@ -185,7 +173,7 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid m_updateProcess->setProgram(m_updateProgram); m_updateProcess->setArguments(m_updateProgramParameters); - connect(m_updateProcess, static_cast(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) { + connect(m_updateProcess, static_cast(&QProcess::finished), this, [=](int exitCode, QProcess::ExitStatus exitStatus) { qCDebug(dcZigbeeController()) << "Update process finihed" << exitCode << exitStatus; if (exitCode != 0) { emit updateFinished(false); @@ -194,7 +182,7 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid } }); - connect(m_updateProcess, &QProcess::readyRead, [=]() { + connect(m_updateProcess, &QProcess::readyRead, this, [=]() { qCDebug(dcZigbeeController()) << "Update process:" << qUtf8Printable(m_updateProcess->readAll()); }); @@ -205,7 +193,7 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid m_factoryResetProcess->setProgram(m_factoryResetProgram); m_factoryResetProcess->setArguments(m_factoryResetParameters); - connect(m_factoryResetProcess, static_cast(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) { + connect(m_factoryResetProcess, static_cast(&QProcess::finished), this, [=](int exitCode, QProcess::ExitStatus exitStatus) { qCDebug(dcZigbeeController()) << "Factory reset process finihed" << exitCode << exitStatus; if (exitCode != 0) { emit updateFinished(false); @@ -222,7 +210,7 @@ FirmwareUpdateHandlerNxp::FirmwareUpdateHandlerNxp(const QFileInfo &updateProvid } }); - connect(m_factoryResetProcess, &QProcess::readyRead, [=]() { + connect(m_factoryResetProcess, &QProcess::readyRead, this, [=]() { qCDebug(dcZigbeeController()) << "Factory reset process:" << qUtf8Printable(m_factoryResetProcess->readAll()); }); @@ -244,11 +232,6 @@ bool FirmwareUpdateHandlerNxp::isValid() const return m_valid; } -QString FirmwareUpdateHandlerNxp::availableFirmwareFileName() const -{ - return m_availableFirmwareFileName; -} - QString FirmwareUpdateHandlerNxp::availableFirmwareVersion() const { return m_availableFirmwareVersion; @@ -262,7 +245,6 @@ void FirmwareUpdateHandlerNxp::startUpdate() } qCDebug(dcZigbeeController()) << "Starting firmware update for NXP controller"; - qCDebug(dcZigbeeController()) << "Firmware file:" << m_availableFirmwareFileName; qCDebug(dcZigbeeController()) << "Firmware version:" << m_availableFirmwareVersion; m_updateProcess->start(); } @@ -275,7 +257,6 @@ void FirmwareUpdateHandlerNxp::startFactoryReset() } qCDebug(dcZigbeeController()) << "Starting factory reset for NXP controller"; - qCDebug(dcZigbeeController()) << "Firmware file:" << m_availableFirmwareFileName; qCDebug(dcZigbeeController()) << "Firmware version:" << m_availableFirmwareVersion; m_factoryResetProcess->start(); } diff --git a/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.h b/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.h index 595078c..2a5d9ab 100644 --- a/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.h +++ b/libnymea-zigbee/backends/nxp/firmwareupdatehandlernxp.h @@ -43,7 +43,6 @@ public: bool updateRunning() const; bool isValid() const; - QString availableFirmwareFileName() const; QString availableFirmwareVersion() const; void startUpdate(); @@ -70,7 +69,6 @@ private: QStringList m_factoryResetParameters; QString m_updateReleaseFilePath; - QString m_availableFirmwareFileName; QString m_availableFirmwareVersion; };