From adf3d945e190d1e697b30aa9b7feae93d3297b38 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 12 May 2018 11:22:54 -0700 Subject: [PATCH] DC transport debugging messages Show the transport types we support for each of the supported dive computers. Signed-off-by: Dirk Hohndel --- core/downloadfromdcthread.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 1c60ca6cf..4c1343bbc 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -166,13 +166,38 @@ void fill_computer_list() qSort(vendorList); } +#define NUMTRANSPORTS 6 +static QString transportStringTable[NUMTRANSPORTS] = { + QStringLiteral("SERIAL"), + QStringLiteral("USB"), + QStringLiteral("USBHID"), + QStringLiteral("IRDA"), + QStringLiteral("BT"), + QStringLiteral("BLE") +}; + +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); qDebug() << "Supported dive computers:"; Q_FOREACH (QString vendor, vendorList) { QString msg = vendor + ": "; Q_FOREACH (QString product, productList[vendor]) { - msg += product + ", "; + dc_descriptor_t *descriptor = descriptorLookup[vendor + product]; + unsigned int transport = dc_descriptor_get_transports(descriptor) & transportMask; + QString transportString = getTransportString(transport); + msg += product + " (" + transportString +"), "; } msg.chop(2); qDebug() << msg;