From 8a5f2ef52fa5f30583104d281ff7e0141fb3e45c Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Thu, 8 Jan 2015 23:14:40 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/configuredivecomputerdialog.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'qt-ui') 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"); -- cgit v1.2.3-70-g09d2