summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-01-08 23:14:40 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-08 14:35:03 -0800
commit8a5f2ef52fa5f30583104d281ff7e0141fb3e45c (patch)
tree42bd8ac7f689c42ba812de2a014b21d10a85c453 /qt-ui
parent4f8536c2537087af8672d337b85729be3fb945b1 (diff)
downloadsubsurface-8a5f2ef52fa5f30583104d281ff7e0141fb3e45c.tar.gz
Only suggest OSTC3 fw upgrade on newer version
Previous code suggested a "upgrade" if your firmware where other than whats parsed from the autofirmware call. This switches that logic into only suggesting firmware upgrade if the found firmware is newer than the firmware your device runs. The previous logic was very annoying if you have a device running a development version of the firmware. If you have taken that step of the guided path, you shouldn't be told to "upgrade" to something older every time you download from your computer. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index b6b10113a..6b50cdadb 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -227,15 +227,22 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data)
{
devData = *data;
parent = _parent;
+ // If we didn't find a current firmware version stop this hole thing here.
+ if (latestFirmwareAvailable.isEmpty())
+ return;
+
// for now libdivecomputer gives us the firmware on device undecoded as integer
// for the OSTC that means highbyte.lowbyte is the version number
int firmwareOnDevice = devData.libdc_firmware;
- QString firmware;
- firmware = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256);
- if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) {
+ QString firmwareOnDeviceString = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256);
+
+ // Convert the latestFirmwareAvailable to a integear we can compare with
+ QStringList fwParts = latestFirmwareAvailable.split(".");
+ int latestFirmwareAvailableNumber = fwParts[0].toInt() * 256 + fwParts[1].toInt();
+ if (latestFirmwareAvailableNumber > firmwareOnDevice) {
QMessageBox response(parent);
QString message = tr("You should update the firmware on your dive computer: you have version %1 but the latest stable version is %2")
- .arg(firmware)
+ .arg(firmwareOnDeviceString)
.arg(latestFirmwareAvailable);
if (strcmp(data->product, "OSTC Sport") == 0)
message += tr("\n\nPlease start Bluetooth on your OSTC Sport and do the same preparations as for a logbook download before continuing with the update");