2017-04-18 17:14:03 +00:00
|
|
|
#include "downloadfromdcthread.h"
|
2024-03-26 13:14:54 +00:00
|
|
|
#include "core/errorhelper.h"
|
2024-04-29 05:02:54 +00:00
|
|
|
#include "core/format.h"
|
2017-04-18 17:14:03 +00:00
|
|
|
#include "core/libdivecomputer.h"
|
2018-02-28 22:37:09 +00:00
|
|
|
#include "core/qthelper.h"
|
2022-11-12 10:12:39 +00:00
|
|
|
#include "core/range.h"
|
2024-04-29 05:02:54 +00:00
|
|
|
#include "core/uemis.h"
|
2018-08-15 09:54:37 +00:00
|
|
|
#include "core/settings/qPrefDiveComputer.h"
|
2019-07-15 21:44:39 +00:00
|
|
|
#include "core/divelist.h"
|
2018-08-09 02:45:40 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
#include "core/subsurface-string.h"
|
|
|
|
#endif
|
2017-04-18 17:14:03 +00:00
|
|
|
|
2017-04-27 18:24:14 +00:00
|
|
|
QStringList vendorList;
|
|
|
|
QHash<QString, QStringList> productList;
|
2018-07-26 01:43:55 +00:00
|
|
|
static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile
|
2017-04-27 18:24:14 +00:00
|
|
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
2017-07-17 04:49:11 +00:00
|
|
|
ConnectionListModel connectionListModel;
|
2017-04-27 18:24:14 +00:00
|
|
|
|
2018-09-21 22:41:28 +00:00
|
|
|
static void updateRememberedDCs()
|
|
|
|
{
|
2018-10-02 17:54:54 +00:00
|
|
|
QString current = qPrefDiveComputer::vendor() + " - " + qPrefDiveComputer::product() + " - " + qPrefDiveComputer::device();
|
2018-09-21 22:41:28 +00:00
|
|
|
QStringList dcs = {
|
2018-10-02 17:54:54 +00:00
|
|
|
qPrefDiveComputer::vendor1() + " - " + qPrefDiveComputer::product1() + " - " + qPrefDiveComputer::device1(),
|
|
|
|
qPrefDiveComputer::vendor2() + " - " + qPrefDiveComputer::product2() + " - " + qPrefDiveComputer::device2(),
|
|
|
|
qPrefDiveComputer::vendor3() + " - " + qPrefDiveComputer::product3() + " - " + qPrefDiveComputer::device3(),
|
|
|
|
qPrefDiveComputer::vendor4() + " - " + qPrefDiveComputer::product4() + " - " + qPrefDiveComputer::device4()
|
2018-09-21 22:41:28 +00:00
|
|
|
};
|
|
|
|
if (dcs.contains(current))
|
|
|
|
// already in the list
|
|
|
|
return;
|
|
|
|
// add the current one as the first remembered one and drop the 4th one
|
|
|
|
// don't get confused by 0-based and 1-based indices!
|
|
|
|
if (dcs[2] != " - ") {
|
|
|
|
qPrefDiveComputer::set_vendor4(qPrefDiveComputer::vendor3());
|
|
|
|
qPrefDiveComputer::set_product4(qPrefDiveComputer::product3());
|
|
|
|
qPrefDiveComputer::set_device4(qPrefDiveComputer::device3());
|
|
|
|
}
|
|
|
|
if (dcs[1] != " - ") {
|
|
|
|
qPrefDiveComputer::set_vendor3(qPrefDiveComputer::vendor2());
|
|
|
|
qPrefDiveComputer::set_product3(qPrefDiveComputer::product2());
|
|
|
|
qPrefDiveComputer::set_device3(qPrefDiveComputer::device2());
|
|
|
|
}
|
|
|
|
if (dcs[0] != " - ") {
|
|
|
|
qPrefDiveComputer::set_vendor2(qPrefDiveComputer::vendor1());
|
|
|
|
qPrefDiveComputer::set_product2(qPrefDiveComputer::product1());
|
|
|
|
qPrefDiveComputer::set_device2(qPrefDiveComputer::device1());
|
|
|
|
}
|
|
|
|
qPrefDiveComputer::set_vendor1(qPrefDiveComputer::vendor());
|
|
|
|
qPrefDiveComputer::set_product1(qPrefDiveComputer::product());
|
|
|
|
qPrefDiveComputer::set_device1(qPrefDiveComputer::device());
|
|
|
|
}
|
|
|
|
|
2022-11-12 10:12:39 +00:00
|
|
|
static QString transportStringTable[] = {
|
2020-10-03 19:59:38 +00:00
|
|
|
QStringLiteral("SERIAL"),
|
|
|
|
QStringLiteral("USB"),
|
|
|
|
QStringLiteral("USBHID"),
|
|
|
|
QStringLiteral("IRDA"),
|
|
|
|
QStringLiteral("BT"),
|
|
|
|
QStringLiteral("BLE"),
|
2022-11-12 10:12:39 +00:00
|
|
|
QStringLiteral("USBSTORAGE")
|
2020-10-03 19:59:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static QString getTransportString(unsigned int transport)
|
|
|
|
{
|
|
|
|
QString ts;
|
2022-11-12 10:12:39 +00:00
|
|
|
for (auto [i, s]: enumerated_range(transportStringTable)) {
|
2020-10-03 19:59:38 +00:00
|
|
|
if (transport & 1 << i)
|
2022-11-12 10:12:39 +00:00
|
|
|
ts += s + ", ";
|
2020-10-03 19:59:38 +00:00
|
|
|
}
|
|
|
|
ts.chop(2);
|
|
|
|
return ts;
|
|
|
|
}
|
2018-09-21 22:41:28 +00:00
|
|
|
|
2022-11-12 11:44:29 +00:00
|
|
|
DownloadThread::DownloadThread() : m_data(DCDeviceData::instance())
|
2017-04-18 17:14:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DownloadThread::run()
|
|
|
|
{
|
2017-05-26 14:40:50 +00:00
|
|
|
auto internalData = m_data->internalData();
|
2020-05-14 19:15:24 +00:00
|
|
|
internalData->descriptor = descriptorLookup[m_data->vendor().toLower() + m_data->product().toLower()];
|
2022-11-12 11:44:29 +00:00
|
|
|
internalData->log = &log;
|
2024-05-02 19:26:22 +00:00
|
|
|
internalData->btname = m_data->devBluetoothName().toStdString();
|
2018-10-10 08:01:02 +00:00
|
|
|
if (!internalData->descriptor) {
|
2024-03-26 13:14:54 +00:00
|
|
|
report_info("No download possible when DC type is unknown");
|
2018-10-10 08:01:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-10-03 19:59:38 +00:00
|
|
|
// get the list of transports that this device supports and filter depending on Bluetooth option
|
|
|
|
unsigned int transports = dc_descriptor_get_transports(internalData->descriptor);
|
|
|
|
if (internalData->bluetooth_mode)
|
|
|
|
transports &= (DC_TRANSPORT_BLE | DC_TRANSPORT_BLUETOOTH);
|
|
|
|
else
|
|
|
|
transports &= ~(DC_TRANSPORT_BLE | DC_TRANSPORT_BLUETOOTH);
|
|
|
|
if (transports == DC_TRANSPORT_USBHID)
|
|
|
|
internalData->devname = "";
|
|
|
|
|
2024-03-26 13:14:54 +00:00
|
|
|
report_info("Starting download from %s", qPrintable(getTransportString(transports)));
|
|
|
|
report_info("downloading %s dives", internalData->force_download ? "all" : "only new");
|
2024-05-13 04:17:07 +00:00
|
|
|
log.clear();
|
2017-05-26 14:40:50 +00:00
|
|
|
|
2022-11-12 11:44:29 +00:00
|
|
|
Q_ASSERT(internalData->log != nullptr);
|
2024-04-29 05:02:54 +00:00
|
|
|
std::string errorText;
|
2017-04-18 17:14:03 +00:00
|
|
|
import_thread_cancelled = false;
|
2017-10-23 22:27:52 +00:00
|
|
|
error.clear();
|
2024-05-02 19:26:22 +00:00
|
|
|
if (internalData->vendor == "Uemis")
|
2017-05-19 09:23:11 +00:00
|
|
|
errorText = do_uemis_import(internalData);
|
2017-04-18 17:14:03 +00:00
|
|
|
else
|
2017-05-19 09:23:11 +00:00
|
|
|
errorText = do_libdivecomputer_import(internalData);
|
2024-04-29 05:02:54 +00:00
|
|
|
if (!errorText.empty()) {
|
|
|
|
error = format_string_std(errorText.c_str(), internalData->devname.c_str(),
|
|
|
|
internalData->vendor.c_str(), internalData->product.c_str());
|
|
|
|
report_info("Finishing download thread: %s", error.c_str());
|
2018-06-21 06:50:11 +00:00
|
|
|
} else {
|
2024-06-07 08:25:09 +00:00
|
|
|
if (log.dives.empty())
|
2024-04-29 05:02:54 +00:00
|
|
|
error = tr("No new dives downloaded from dive computer").toStdString();
|
2024-06-07 08:25:09 +00:00
|
|
|
report_info("Finishing download thread: %d dives downloaded", static_cast<int>(log.dives.size()));
|
2018-06-21 06:50:11 +00:00
|
|
|
}
|
2024-05-02 19:26:22 +00:00
|
|
|
qPrefDiveComputer::set_vendor(internalData->vendor.c_str());
|
|
|
|
qPrefDiveComputer::set_product(internalData->product.c_str());
|
|
|
|
qPrefDiveComputer::set_device(internalData->devname.c_str());
|
2018-08-15 09:54:37 +00:00
|
|
|
qPrefDiveComputer::set_device_name(m_data->devBluetoothName());
|
2018-09-21 22:41:28 +00:00
|
|
|
|
|
|
|
updateRememberedDCs();
|
2017-04-18 17:14:03 +00:00
|
|
|
}
|
2017-04-27 18:24:14 +00:00
|
|
|
|
|
|
|
void fill_computer_list()
|
|
|
|
{
|
|
|
|
dc_iterator_t *iterator = NULL;
|
|
|
|
dc_descriptor_t *descriptor = NULL;
|
|
|
|
|
2018-04-25 22:51:35 +00:00
|
|
|
unsigned int transportMask = get_supported_transports(NULL);
|
2018-04-19 04:19:14 +00:00
|
|
|
|
2017-04-27 18:24:14 +00:00
|
|
|
dc_descriptor_iterator(&iterator);
|
|
|
|
while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
|
2018-04-19 10:15:49 +00:00
|
|
|
// mask out the transports that aren't supported
|
2018-04-25 22:51:35 +00:00
|
|
|
unsigned int transports = dc_descriptor_get_transports(descriptor) & transportMask;
|
2018-04-19 10:15:49 +00:00
|
|
|
if (transports == 0)
|
2018-04-19 04:19:14 +00:00
|
|
|
// none of the transports are available, skip
|
|
|
|
continue;
|
|
|
|
|
2017-04-27 18:24:14 +00:00
|
|
|
const char *vendor = dc_descriptor_get_vendor(descriptor);
|
|
|
|
const char *product = dc_descriptor_get_product(descriptor);
|
|
|
|
if (!vendorList.contains(vendor))
|
|
|
|
vendorList.append(vendor);
|
|
|
|
if (!productList[vendor].contains(product))
|
2018-04-19 10:15:49 +00:00
|
|
|
productList[vendor].append(product);
|
2017-04-27 18:24:14 +00:00
|
|
|
|
2020-05-14 19:15:24 +00:00
|
|
|
descriptorLookup[QString(vendor).toLower() + QString(product).toLower()] = descriptor;
|
2017-04-27 18:24:14 +00:00
|
|
|
}
|
|
|
|
dc_iterator_free(iterator);
|
2024-03-16 15:50:43 +00:00
|
|
|
for (const QString &vendor: vendorList) {
|
2019-04-03 18:21:53 +00:00
|
|
|
auto &l = productList[vendor];
|
|
|
|
std::sort(l.begin(), l.end());
|
|
|
|
}
|
2017-04-27 18:24:14 +00:00
|
|
|
|
2017-06-22 09:27:51 +00:00
|
|
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
|
|
|
/* currently suppress the Uemis Zurich on Q_OS_ANDROID and Q_OS_IOS,
|
|
|
|
* as it is no BT device */
|
|
|
|
|
2017-04-27 18:24:14 +00:00
|
|
|
/* and add the Uemis Zurich which we are handling internally
|
|
|
|
THIS IS A HACK as we magically have a data structure here that
|
|
|
|
happens to match a data structure that is internal to libdivecomputer;
|
|
|
|
this WILL BREAK if libdivecomputer changes the dc_descriptor struct...
|
|
|
|
eventually the UEMIS code needs to move into libdivecomputer, I guess */
|
2017-07-19 13:14:18 +00:00
|
|
|
struct mydescriptor *mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor));
|
2017-04-27 18:24:14 +00:00
|
|
|
mydescriptor->vendor = "Uemis";
|
|
|
|
mydescriptor->product = "Zurich";
|
|
|
|
mydescriptor->type = DC_FAMILY_NULL;
|
|
|
|
mydescriptor->model = 0;
|
2018-08-27 17:32:14 +00:00
|
|
|
mydescriptor->transports = DC_TRANSPORT_USBSTORAGE;
|
2017-04-27 18:24:14 +00:00
|
|
|
|
|
|
|
if (!vendorList.contains("Uemis"))
|
|
|
|
vendorList.append("Uemis");
|
|
|
|
|
|
|
|
if (!productList["Uemis"].contains("Zurich"))
|
|
|
|
productList["Uemis"].push_back("Zurich");
|
|
|
|
|
2020-05-14 19:15:24 +00:00
|
|
|
// note: keys in the descriptorLookup are always lowercase
|
|
|
|
descriptorLookup["uemiszurich"] = (dc_descriptor_t *)mydescriptor;
|
2017-06-22 09:27:51 +00:00
|
|
|
#endif
|
2017-04-27 18:24:14 +00:00
|
|
|
|
2019-04-03 18:21:53 +00:00
|
|
|
std::sort(vendorList.begin(), vendorList.end());
|
2017-04-27 18:24:14 +00:00
|
|
|
}
|
2017-05-12 17:18:20 +00:00
|
|
|
|
2018-04-19 13:37:13 +00:00
|
|
|
void show_computer_list()
|
|
|
|
{
|
2018-05-12 18:22:54 +00:00
|
|
|
unsigned int transportMask = get_supported_transports(NULL);
|
2024-03-26 13:14:54 +00:00
|
|
|
report_info("Supported dive computers:");
|
2024-03-16 15:50:43 +00:00
|
|
|
for (const QString &vendor: vendorList) {
|
2018-04-19 13:37:13 +00:00
|
|
|
QString msg = vendor + ": ";
|
2024-03-16 15:50:43 +00:00
|
|
|
for (const QString &product: productList[vendor]) {
|
2020-05-14 19:15:24 +00:00
|
|
|
dc_descriptor_t *descriptor = descriptorLookup[vendor.toLower() + product.toLower()];
|
2018-05-12 18:22:54 +00:00
|
|
|
unsigned int transport = dc_descriptor_get_transports(descriptor) & transportMask;
|
|
|
|
QString transportString = getTransportString(transport);
|
2018-07-26 01:43:55 +00:00
|
|
|
msg += product + " (" + transportString + "), ";
|
2018-04-19 13:37:13 +00:00
|
|
|
}
|
|
|
|
msg.chop(2);
|
2024-03-26 13:14:54 +00:00
|
|
|
report_info("%s", qPrintable(msg));
|
2018-04-19 13:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-06 02:41:57 +00:00
|
|
|
|
2018-06-09 14:59:02 +00:00
|
|
|
DCDeviceData::DCDeviceData()
|
2017-05-19 09:23:11 +00:00
|
|
|
{
|
2022-11-12 11:44:29 +00:00
|
|
|
data.log = nullptr;
|
2017-05-19 09:23:11 +00:00
|
|
|
data.diveid = 0;
|
2018-07-29 00:23:48 +00:00
|
|
|
#if defined(BT_SUPPORT)
|
2018-06-09 14:46:19 +00:00
|
|
|
data.bluetooth_mode = true;
|
2018-07-29 00:23:48 +00:00
|
|
|
#else
|
|
|
|
data.bluetooth_mode = false;
|
|
|
|
#endif
|
2018-06-09 14:46:19 +00:00
|
|
|
data.force_download = false;
|
|
|
|
data.libdc_dump = false;
|
2018-06-27 23:00:31 +00:00
|
|
|
#if defined(SUBSURFACE_MOBILE)
|
|
|
|
data.libdc_log = true;
|
|
|
|
#else
|
2018-06-09 14:46:19 +00:00
|
|
|
data.libdc_log = false;
|
2018-06-27 23:00:31 +00:00
|
|
|
#endif
|
2020-03-15 01:11:46 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
data.androidUsbDeviceDescriptor = nullptr;
|
|
|
|
#endif
|
2023-04-02 06:28:33 +00:00
|
|
|
data.sync_time = false;
|
2017-05-19 09:23:11 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
DCDeviceData *DCDeviceData::instance()
|
|
|
|
{
|
2018-12-10 14:21:50 +00:00
|
|
|
static DCDeviceData self;
|
|
|
|
return &self;
|
2017-06-06 02:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
|
|
|
|
{
|
|
|
|
return productList[vendor];
|
|
|
|
}
|
|
|
|
|
2024-05-04 20:53:05 +00:00
|
|
|
int DCDeviceData::getMatchingAddress(const QString &, const QString &product)
|
2017-07-17 04:49:11 +00:00
|
|
|
{
|
2019-03-20 14:31:24 +00:00
|
|
|
return connectionListModel.indexOf(product);
|
2017-07-17 04:49:11 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
DCDeviceData *DownloadThread::data()
|
2017-05-19 09:23:11 +00:00
|
|
|
{
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
QString DCDeviceData::vendor() const
|
|
|
|
{
|
2024-05-02 19:26:22 +00:00
|
|
|
return QString::fromStdString(data.vendor);
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::product() const
|
|
|
|
{
|
2024-05-02 19:26:22 +00:00
|
|
|
return QString::fromStdString(data.product);
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::devName() const
|
|
|
|
{
|
2024-05-02 19:26:22 +00:00
|
|
|
return QString::fromStdString(data.devname);
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 11:33:20 +00:00
|
|
|
QString DCDeviceData::devBluetoothName() const
|
|
|
|
{
|
|
|
|
return m_devBluetoothName;
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
QString DCDeviceData::descriptor() const
|
|
|
|
{
|
2024-03-26 13:14:54 +00:00
|
|
|
return QString();
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::bluetoothMode() const
|
|
|
|
{
|
|
|
|
return data.bluetooth_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::forceDownload() const
|
|
|
|
{
|
|
|
|
return data.force_download;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DCDeviceData::diveId() const
|
|
|
|
{
|
|
|
|
return data.diveid;
|
|
|
|
}
|
|
|
|
|
2023-04-02 06:28:33 +00:00
|
|
|
bool DCDeviceData::syncTime() const
|
|
|
|
{
|
|
|
|
return data.sync_time;
|
|
|
|
}
|
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
void DCDeviceData::setVendor(const QString &vendor)
|
2017-05-12 17:18:20 +00:00
|
|
|
{
|
2024-05-02 19:26:22 +00:00
|
|
|
data.vendor = vendor.toStdString();
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
void DCDeviceData::setProduct(const QString &product)
|
2017-05-12 17:18:20 +00:00
|
|
|
{
|
2024-05-02 19:26:22 +00:00
|
|
|
data.product = product.toStdString();
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
void DCDeviceData::setDevName(const QString &devName)
|
2017-05-12 17:18:20 +00:00
|
|
|
{
|
2017-12-31 11:10:37 +00:00
|
|
|
// This is a workaround for bug #1002. A string of the form "devicename (deviceaddress)"
|
|
|
|
// or "deviceaddress (devicename)" may have found its way into the preferences.
|
|
|
|
// Try to fetch the address from such a string
|
|
|
|
// TODO: Remove this code in due course
|
|
|
|
if (data.bluetooth_mode) {
|
|
|
|
int idx1 = devName.indexOf('(');
|
|
|
|
int idx2 = devName.lastIndexOf(')');
|
|
|
|
if (idx1 >= 0 && idx2 >= 0 && idx2 > idx1) {
|
|
|
|
QString front = devName.left(idx1).trimmed();
|
|
|
|
QString back = devName.mid(idx1 + 1, idx2 - idx1 - 1);
|
|
|
|
QString newDevName = back.indexOf(':') >= 0 ? back : front;
|
|
|
|
qWarning() << "Found invalid bluetooth device" << devName << "corrected to" << newDevName << ".";
|
2024-05-02 19:26:22 +00:00
|
|
|
data.devname = newDevName.toStdString();
|
2017-12-31 11:10:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-05-02 19:26:22 +00:00
|
|
|
data.devname = devName.toStdString();
|
2017-05-12 17:18:20 +00:00
|
|
|
}
|
|
|
|
|
2020-03-15 01:11:46 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
2020-03-15 22:12:30 +00:00
|
|
|
void DCDeviceData::setUsbDevice(const android_usb_serial_device_descriptor &usbDescriptor)
|
2020-03-15 01:11:46 +00:00
|
|
|
{
|
2020-03-15 22:12:30 +00:00
|
|
|
androidUsbDescriptor = usbDescriptor;
|
|
|
|
data.androidUsbDeviceDescriptor = &androidUsbDescriptor;
|
2020-03-15 01:11:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
void DCDeviceData::setDevBluetoothName(const QString &name)
|
2017-11-12 11:33:20 +00:00
|
|
|
{
|
|
|
|
m_devBluetoothName = name;
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
void DCDeviceData::setBluetoothMode(bool mode)
|
|
|
|
{
|
|
|
|
data.bluetooth_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setForceDownload(bool force)
|
|
|
|
{
|
|
|
|
data.force_download = force;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setDiveId(int diveId)
|
|
|
|
{
|
|
|
|
data.diveid = diveId;
|
|
|
|
}
|
2017-05-19 09:23:11 +00:00
|
|
|
|
2023-04-02 06:28:33 +00:00
|
|
|
void DCDeviceData::setSyncTime(bool syncTime)
|
|
|
|
{
|
|
|
|
data.sync_time = syncTime;
|
|
|
|
}
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
void DCDeviceData::setSaveDump(bool save)
|
|
|
|
{
|
|
|
|
data.libdc_dump = save;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::saveDump() const
|
|
|
|
{
|
|
|
|
return data.libdc_dump;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setSaveLog(bool saveLog)
|
|
|
|
{
|
|
|
|
data.libdc_log = saveLog;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::saveLog() const
|
|
|
|
{
|
|
|
|
return data.libdc_log;
|
|
|
|
}
|
2018-06-09 10:31:31 +00:00
|
|
|
|
2018-07-26 01:43:55 +00:00
|
|
|
device_data_t *DCDeviceData::internalData()
|
2017-05-19 09:23:11 +00:00
|
|
|
{
|
|
|
|
return &data;
|
|
|
|
}
|
2017-06-06 02:41:57 +00:00
|
|
|
|
2017-08-26 19:27:12 +00:00
|
|
|
int DCDeviceData::getDetectedVendorIndex()
|
2017-06-06 02:41:57 +00:00
|
|
|
{
|
|
|
|
#if defined(BT_SUPPORT)
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 08:09:56 +00:00
|
|
|
|
2017-07-17 14:43:31 +00:00
|
|
|
// Pick the vendor of the first confirmed find of a DC (if any)
|
|
|
|
if (!btDCs.isEmpty())
|
2017-06-06 02:41:57 +00:00
|
|
|
return btDCs.first().vendorIdx;
|
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-08-26 19:27:12 +00:00
|
|
|
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText)
|
2017-06-06 02:41:57 +00:00
|
|
|
{
|
|
|
|
#if defined(BT_SUPPORT)
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 08:09:56 +00:00
|
|
|
|
|
|
|
// Display in the QML UI, the first found dive computer that is been
|
|
|
|
// detected as a possible real dive computer (and not some other paired
|
2017-07-17 14:43:31 +00:00
|
|
|
// BT device)
|
|
|
|
if (!btDCs.isEmpty())
|
2017-06-06 02:41:57 +00:00
|
|
|
return btDCs.first().productIdx;
|
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|