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 <[email protected]> --- qt-ui/configuredivecomputerdialog.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index b6b1011..6b50cda 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"); -- 2.1.0 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
