mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Notify Ostc 4 users about new firmwares
This adds support for notifying Ostc 4 users about new firmwares when they download dives from their computers, gives them the option to trigger the upgrade flow. Signed-off-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
parent
a5232a30b0
commit
4714f50eae
2 changed files with 24 additions and 8 deletions
|
@ -233,6 +233,9 @@ OstcFirmwareCheck::OstcFirmwareCheck(QString product) : parent(0)
|
||||||
} else if (product == "OSTC Sport") {
|
} else if (product == "OSTC Sport") {
|
||||||
url = QUrl("http://www.heinrichsweikamp.net/autofirmware/ostc_sport_changelog.txt");
|
url = QUrl("http://www.heinrichsweikamp.net/autofirmware/ostc_sport_changelog.txt");
|
||||||
latestFirmwareHexFile = QString("http://www.heinrichsweikamp.net/autofirmware/ostc_sport_firmware.hex");
|
latestFirmwareHexFile = QString("http://www.heinrichsweikamp.net/autofirmware/ostc_sport_firmware.hex");
|
||||||
|
} else if (product == "OSTC 4") {
|
||||||
|
url = QUrl("http://www.heinrichsweikamp.net/autofirmware/ostc4_changelog.txt");
|
||||||
|
latestFirmwareHexFile = QString("http://www.heinrichsweikamp.net/autofirmware/ostc4_firmware.bin");
|
||||||
} else { // not one of the known dive computers
|
} else { // not one of the known dive computers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -260,15 +263,27 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data)
|
||||||
|
|
||||||
// libdivecomputer gives us the firmware on device as an integer
|
// libdivecomputer gives us the firmware on device as an integer
|
||||||
// for the OSTC that means highbyte.lowbyte is the version number
|
// for the OSTC that means highbyte.lowbyte is the version number
|
||||||
// For OSTC 4's there is actually a another minor, x.y.Z, but its not
|
// For OSTC 4's its stored as XXXX XYYY YYZZ ZZZB, -> X.Y.Z beta?
|
||||||
// exposed via libdivecomputer, so we won't trigger this update flow
|
|
||||||
// when the Z changes
|
|
||||||
int firmwareOnDevice = devData.libdc_firmware;
|
|
||||||
QString firmwareOnDeviceString = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256);
|
|
||||||
|
|
||||||
|
int firmwareOnDevice = devData.libdc_firmware;
|
||||||
|
QString firmwareOnDeviceString;
|
||||||
// Convert the latestFirmwareAvailable to a integear we can compare with
|
// Convert the latestFirmwareAvailable to a integear we can compare with
|
||||||
QStringList fwParts = latestFirmwareAvailable.split(".");
|
QStringList fwParts = latestFirmwareAvailable.split(".");
|
||||||
int latestFirmwareAvailableNumber = fwParts[0].toInt() * 256 + fwParts[1].toInt();
|
int latestFirmwareAvailableNumber;
|
||||||
|
|
||||||
|
if (strcmp(data->product, "OSTC 4") == 0) {
|
||||||
|
unsigned char X, Y, Z, beta;
|
||||||
|
X = (firmwareOnDevice & 0xF800) >> 11;
|
||||||
|
Y = (firmwareOnDevice & 0x07C0) >> 6;
|
||||||
|
Z = (firmwareOnDevice & 0x003E) >> 1;
|
||||||
|
beta = firmwareOnDevice & 0x0001;
|
||||||
|
firmwareOnDeviceString = QString("%1.%2.%3%4").arg(X).arg(Y).arg(Z).arg(beta?" beta":"");
|
||||||
|
latestFirmwareAvailableNumber = (fwParts[0].toInt() << 11) + (fwParts[1].toInt() << 6) + (fwParts[2].toInt() << 1);
|
||||||
|
} else { // OSTC 3, Sport, Cr
|
||||||
|
firmwareOnDeviceString = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256);
|
||||||
|
latestFirmwareAvailableNumber = fwParts[0].toInt() * 256 + fwParts[1].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
if (latestFirmwareAvailableNumber > firmwareOnDevice) {
|
if (latestFirmwareAvailableNumber > firmwareOnDevice) {
|
||||||
QMessageBox response(parent);
|
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")
|
QString message = tr("You should update the firmware on your dive computer: you have version %1 but the latest stable version is %2")
|
||||||
|
@ -297,7 +312,7 @@ void OstcFirmwareCheck::upgradeFirmware()
|
||||||
QFileInfo fi(filename);
|
QFileInfo fi(filename);
|
||||||
filename = fi.absolutePath().append(QDir::separator()).append(saveFileName);
|
filename = fi.absolutePath().append(QDir::separator()).append(saveFileName);
|
||||||
storeFirmware = QFileDialog::getSaveFileName(parent, tr("Save the downloaded firmware as"),
|
storeFirmware = QFileDialog::getSaveFileName(parent, tr("Save the downloaded firmware as"),
|
||||||
filename, tr("HEX files (*.hex)"));
|
filename, tr("Firmware files (*.hex *.bin)"));
|
||||||
if (storeFirmware.isEmpty())
|
if (storeFirmware.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,8 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
// this check will compair apples and oranges, firmware wise, then.
|
// this check will compair apples and oranges, firmware wise, then.
|
||||||
QString product(ui.product->currentText());
|
QString product(ui.product->currentText());
|
||||||
if (product == "OSTC 3" || product == "OSTC 3+" ||
|
if (product == "OSTC 3" || product == "OSTC 3+" ||
|
||||||
product == "OSTC Cr" || product == "OSTC Sport")
|
product == "OSTC Cr" || product == "OSTC Sport" ||
|
||||||
|
product == "OSTC 4")
|
||||||
ostcFirmwareCheck = new OstcFirmwareCheck(product);
|
ostcFirmwareCheck = new OstcFirmwareCheck(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue