summaryrefslogtreecommitdiffstats
path: root/qt-ui/configuredivecomputerdialog.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-27 08:31:51 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-27 08:31:51 -0800
commit52084c80f7f03f8e8066bc7ccf9f747a38cbd60c (patch)
treef077e98775f53876ef8c6954f7625b5673c6a7a3 /qt-ui/configuredivecomputerdialog.cpp
parent9f95f3ce18a1c25b0407335f472987c64940153d (diff)
downloadsubsurface-52084c80f7f03f8e8066bc7ccf9f747a38cbd60c.tar.gz
Move OSTC firmware check around a bit
This rearranges the code so we can call it from the download dialog and tell the user if there is a newer version of the firmware available. This needs a proper dialog and needs to be hooked up so that the user can accept the suggestion and go directly to the firmware update code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/configuredivecomputerdialog.cpp')
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index 4acbf90e3..546032e63 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -187,16 +187,32 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) :
}
settings.endGroup();
settings.endGroup();
+}
+OstcFirmwareCheck::OstcFirmwareCheck()
+{
hwVersionPage.mainFrame()->load(QUrl("http://www.heinrichsweikamp.com/?id=162"));
- connect(&hwVersionPage, SIGNAL(loadFinished(bool)), this, SLOT(findVersion()));
+ connect(&hwVersionPage, SIGNAL(loadFinished(bool)), this, SLOT(parseOstcFwVersion()));
}
-void ConfigureDiveComputerDialog::findVersion()
+void OstcFirmwareCheck::parseOstcFwVersion()
{
QWebElement parse = hwVersionPage.mainFrame()->documentElement();
QWebElement result = parse.findFirst("div[id=content_firmware_headline_typ0]");
- qDebug() << "Version" << result.toPlainText();
+ latestFirmwareAvailable = result.toPlainText().trimmed();
+ qDebug() << "Latest OSTC 3 Version" << latestFirmwareAvailable;
+}
+
+void OstcFirmwareCheck::checkLatest(uint32_t firmwareOnDevice)
+{
+ // for now libdivecomputer gives us the firmware on device undecoded as integer
+ // for the OSTC that means highbyte.lowbyte is the version number
+ QString firmware;
+ firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256);
+ if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) {
+ qDebug() << "you should update your firmware: you have" << firmware <<
+ "but the latest stable version is" << latestFirmwareAvailable;
+ }
}
ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog()