diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-10-03 12:59:38 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-05 12:42:40 -0700 |
commit | f775ec2e69cff46bb967f46cdb5d47fbb9e69274 (patch) | |
tree | 118cc09fc8bd94b5584e72b93b657802ec71e2a8 /core/downloadfromdcthread.cpp | |
parent | 1065a526358809019f7ec93eb3b8169f98baebf1 (diff) | |
download | subsurface-f775ec2e69cff46bb967f46cdb5d47fbb9e69274.tar.gz |
download from dive computer: correctly list transports tried
Instead of just 'BT' or 'device name' (which is wrong in cases where we don't
use a device name in the first place, like USBHID), try to list the actual
transports that we will consider.
A big part of this patch is just moving code around so we don't need a forward
declaration of the static helper function.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r-- | core/downloadfromdcthread.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index d8a65c809..0ba4433eb 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -58,6 +58,27 @@ static void updateRememberedDCs() qPrefDiveComputer::set_device1(qPrefDiveComputer::device()); } +#define NUMTRANSPORTS 7 +static QString transportStringTable[NUMTRANSPORTS] = { + QStringLiteral("SERIAL"), + QStringLiteral("USB"), + QStringLiteral("USBHID"), + QStringLiteral("IRDA"), + QStringLiteral("BT"), + QStringLiteral("BLE"), + QStringLiteral("USBSTORAGE"), +}; + +static QString getTransportString(unsigned int transport) +{ + QString ts; + for (int i = 0; i < NUMTRANSPORTS; i++) { + if (transport & 1 << i) + ts += transportStringTable[i] + ", "; + } + ts.chop(2); + return ts; +} DownloadThread::DownloadThread() : downloadTable({ 0 }), diveSiteTable({ 0 }), @@ -76,7 +97,16 @@ void DownloadThread::run() qDebug() << "No download possible when DC type is unknown"; return; } - qDebug() << "Starting download from " << (internalData->bluetooth_mode ? "BT" : internalData->devname); + // 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 = ""; + + qDebug() << "Starting download from " << getTransportString(transports); qDebug() << "downloading" << (internalData->force_download ? "all" : "only new") << "dives"; clear_dive_table(&downloadTable); clear_dive_site_table(&diveSiteTable); @@ -164,28 +194,6 @@ void fill_computer_list() std::sort(vendorList.begin(), vendorList.end()); } -#define NUMTRANSPORTS 7 -static QString transportStringTable[NUMTRANSPORTS] = { - QStringLiteral("SERIAL"), - QStringLiteral("USB"), - QStringLiteral("USBHID"), - QStringLiteral("IRDA"), - QStringLiteral("BT"), - QStringLiteral("BLE"), - QStringLiteral("USBSTORAGE"), -}; - -static QString getTransportString(unsigned int transport) -{ - QString ts; - for (int i = 0; i < NUMTRANSPORTS; i++) { - if (transport & 1 << i) - ts += transportStringTable[i] + ", "; - } - ts.chop(2); - return ts; -} - void show_computer_list() { unsigned int transportMask = get_supported_transports(NULL); |