2020-11-15 03:44:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "qt-models/diveimportedmodel.h"
|
|
|
|
|
|
|
|
void cliDownloader(const char *vendor, const char *product, const char *device)
|
|
|
|
{
|
2021-01-26 17:45:46 +00:00
|
|
|
DiveImportedModel diveImportedModel;
|
|
|
|
DiveImportedModel::connect(&diveImportedModel, &DiveImportedModel::downloadFinished, [] {
|
2020-11-15 03:44:06 +00:00
|
|
|
// do something useful at the end of the download
|
2020-11-22 19:31:57 +00:00
|
|
|
printf("Finished\n");
|
2020-11-15 03:44:06 +00:00
|
|
|
});
|
|
|
|
|
2021-01-26 17:45:46 +00:00
|
|
|
auto data = diveImportedModel.thread.data();
|
2020-11-15 03:44:06 +00:00
|
|
|
data->setVendor(vendor);
|
|
|
|
data->setProduct(product);
|
2020-11-22 19:31:57 +00:00
|
|
|
data->setBluetoothMode(false);
|
2020-11-15 03:44:06 +00:00
|
|
|
if (data->vendor() == "Uemis") {
|
2021-01-26 18:00:48 +00:00
|
|
|
QString devname(device);
|
|
|
|
int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
|
|
|
|
if (colon >= 0) {
|
|
|
|
devname.truncate(colon + 2);
|
|
|
|
fprintf(stderr, "shortened devname to \"%s\"", qPrintable(devname));
|
2020-11-15 03:44:06 +00:00
|
|
|
}
|
|
|
|
data->setDevName(devname);
|
|
|
|
} else {
|
|
|
|
data->setDevName(device);
|
|
|
|
}
|
|
|
|
|
2021-01-26 17:45:46 +00:00
|
|
|
// some assumptions - should all be configurable
|
2020-11-15 03:44:06 +00:00
|
|
|
data->setForceDownload(false);
|
2020-11-22 19:31:57 +00:00
|
|
|
data->setSaveLog(true);
|
2020-11-15 03:44:06 +00:00
|
|
|
data->setSaveDump(false);
|
|
|
|
|
2021-01-26 17:45:46 +00:00
|
|
|
diveImportedModel.startDownload();
|
|
|
|
diveImportedModel.waitForDownload();
|
|
|
|
diveImportedModel.recordDives();
|
2020-11-15 03:44:06 +00:00
|
|
|
}
|