2017-04-18 19:14:03 +02:00
|
|
|
#include "downloadfromdcthread.h"
|
|
|
|
#include "core/libdivecomputer.h"
|
2017-05-26 14:07:02 +02:00
|
|
|
#include <QDebug>
|
2017-07-03 17:28:27 -07:00
|
|
|
#include <QRegularExpression>
|
2017-04-18 19:14:03 +02:00
|
|
|
|
2017-04-27 20:24:14 +02:00
|
|
|
QStringList vendorList;
|
|
|
|
QHash<QString, QStringList> productList;
|
2017-06-22 11:27:51 +02:00
|
|
|
static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile
|
2017-04-27 20:24:14 +02:00
|
|
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
|
|
|
|
2017-04-18 19:14:03 +02:00
|
|
|
static QString str_error(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
const QString str = QString().vsprintf(fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2017-06-08 13:38:52 +02:00
|
|
|
DownloadThread::DownloadThread()
|
2017-04-18 19:14:03 +02:00
|
|
|
{
|
2017-06-08 13:38:52 +02:00
|
|
|
m_data = DCDeviceData::instance();
|
2017-04-18 19:14:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DownloadThread::run()
|
|
|
|
{
|
2017-05-26 16:40:50 +02:00
|
|
|
auto internalData = m_data->internalData();
|
|
|
|
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
|
|
|
|
internalData->download_table = &downloadTable;
|
2017-05-29 15:05:46 -07:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
// on Android we either use BT or we download via FTDI cable
|
2017-05-30 17:47:22 -07:00
|
|
|
if (!internalData->bluetooth_mode)
|
|
|
|
internalData->devname = "ftdi";
|
2017-05-29 15:05:46 -07:00
|
|
|
#endif
|
|
|
|
qDebug() << "Starting download from " << (internalData->bluetooth_mode ? "BT" : internalData->devname);
|
2017-05-26 16:40:50 +02:00
|
|
|
downloadTable.nr = 0;
|
|
|
|
qDebug() << "Starting the thread" << downloadTable.nr;
|
2017-05-28 17:48:56 +02:00
|
|
|
dive_table.preexisting = dive_table.nr;
|
2017-05-26 16:40:50 +02:00
|
|
|
|
2017-05-19 11:23:11 +02:00
|
|
|
Q_ASSERT(internalData->download_table != nullptr);
|
2017-04-18 19:14:03 +02:00
|
|
|
const char *errorText;
|
|
|
|
import_thread_cancelled = false;
|
2017-05-19 11:23:11 +02:00
|
|
|
if (!strcmp(internalData->vendor, "Uemis"))
|
|
|
|
errorText = do_uemis_import(internalData);
|
2017-04-18 19:14:03 +02:00
|
|
|
else
|
2017-05-19 11:23:11 +02:00
|
|
|
errorText = do_libdivecomputer_import(internalData);
|
2017-04-18 19:14:03 +02:00
|
|
|
if (errorText)
|
2017-05-19 11:23:11 +02:00
|
|
|
error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
|
2017-05-26 16:40:50 +02:00
|
|
|
|
|
|
|
qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
|
2017-04-18 19:14:03 +02:00
|
|
|
}
|
2017-04-27 20:24:14 +02:00
|
|
|
|
2017-06-22 11:27:51 +02:00
|
|
|
static void fill_supported_mobile_list()
|
|
|
|
{
|
|
|
|
/* currently no BLE devices added as BLE backend is not ready yet */
|
|
|
|
|
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
/* BT, BLE and FTDI devices */
|
|
|
|
mobileProductList["Heinrichs Weikamp"] =
|
|
|
|
QStringList({{"OSTC Sport"}, {"OSTC 2N"}, {"OSTC 3"},
|
|
|
|
{"OSTC 3+"}, {"OSTC 4"}});
|
|
|
|
mobileProductList["Shearwater"] =
|
|
|
|
QStringList({{"Petrel"}, {"Petrel 2"}, {"Perdix"}});
|
2017-06-23 21:29:34 -07:00
|
|
|
mobileProductList["Suunto"] =
|
|
|
|
QStringList({"EON Steel"});
|
2017-07-02 21:57:08 -07:00
|
|
|
mobileProductList["Scubapro"] =
|
|
|
|
QStringList({{"G2"}});
|
2017-06-23 21:29:34 -07:00
|
|
|
|
2017-06-22 11:27:51 +02:00
|
|
|
#endif
|
|
|
|
#if defined(Q_OS_IOS)
|
|
|
|
/* BLE only, Qt does not support classic BT on iOS */
|
2017-07-02 21:57:08 -07:00
|
|
|
mobileProductList["Heinrichs Weikamp"] =
|
|
|
|
QStringList({{"OSTC 4"}});
|
|
|
|
mobileProductList["Shearwater"] =
|
|
|
|
QStringList({{"Petrel"}, {"Petrel 2"}, {"Perdix"}});
|
|
|
|
mobileProductList["Suunto"] =
|
|
|
|
QStringList({"EON Steel"});
|
|
|
|
mobileProductList["Scubapro"] =
|
|
|
|
QStringList({{"G2"}});
|
2017-06-22 11:27:51 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-04-27 20:24:14 +02:00
|
|
|
void fill_computer_list()
|
|
|
|
{
|
|
|
|
dc_iterator_t *iterator = NULL;
|
|
|
|
dc_descriptor_t *descriptor = NULL;
|
|
|
|
struct mydescriptor *mydescriptor;
|
|
|
|
|
2017-06-22 11:27:51 +02:00
|
|
|
fill_supported_mobile_list();
|
|
|
|
|
2017-04-27 20:24:14 +02:00
|
|
|
dc_descriptor_iterator(&iterator);
|
|
|
|
while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
|
|
|
|
const char *vendor = dc_descriptor_get_vendor(descriptor);
|
|
|
|
const char *product = dc_descriptor_get_product(descriptor);
|
2017-06-22 11:27:51 +02:00
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
|
|
|
if (!mobileProductList.contains(vendor))
|
|
|
|
continue;
|
|
|
|
#endif
|
2017-04-27 20:24:14 +02:00
|
|
|
if (!vendorList.contains(vendor))
|
|
|
|
vendorList.append(vendor);
|
2017-06-22 11:27:51 +02:00
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
|
|
|
if (!mobileProductList[vendor].contains(product))
|
|
|
|
continue;
|
|
|
|
#endif
|
2017-04-27 20:24:14 +02:00
|
|
|
if (!productList[vendor].contains(product))
|
|
|
|
productList[vendor].push_back(product);
|
|
|
|
|
|
|
|
descriptorLookup[QString(vendor) + QString(product)] = descriptor;
|
|
|
|
}
|
|
|
|
dc_iterator_free(iterator);
|
|
|
|
Q_FOREACH (QString vendor, vendorList)
|
|
|
|
qSort(productList[vendor]);
|
|
|
|
|
2017-06-22 11:27:51 +02: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 20:24:14 +02: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 */
|
|
|
|
|
|
|
|
mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor));
|
|
|
|
mydescriptor->vendor = "Uemis";
|
|
|
|
mydescriptor->product = "Zurich";
|
|
|
|
mydescriptor->type = DC_FAMILY_NULL;
|
|
|
|
mydescriptor->model = 0;
|
|
|
|
|
|
|
|
if (!vendorList.contains("Uemis"))
|
|
|
|
vendorList.append("Uemis");
|
|
|
|
|
|
|
|
if (!productList["Uemis"].contains("Zurich"))
|
|
|
|
productList["Uemis"].push_back("Zurich");
|
|
|
|
|
|
|
|
descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor;
|
2017-06-22 11:27:51 +02:00
|
|
|
#endif
|
2017-04-27 20:24:14 +02:00
|
|
|
|
|
|
|
qSort(vendorList);
|
2017-06-05 09:19:15 -07:00
|
|
|
#if defined(SUBSURFACE_MOBILE) && defined(BT_SUPPORT)
|
|
|
|
vendorList.append(QObject::tr("Paired Bluetooth Devices"));
|
|
|
|
#endif
|
2017-04-27 20:24:14 +02:00
|
|
|
}
|
2017-05-12 19:18:20 +02:00
|
|
|
|
2017-06-05 19:41:57 -07:00
|
|
|
DCDeviceData *DCDeviceData::m_instance = NULL;
|
|
|
|
|
2017-05-19 11:23:11 +02:00
|
|
|
DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
|
|
|
|
{
|
2017-06-05 19:41:57 -07:00
|
|
|
if (m_instance) {
|
|
|
|
qDebug() << "already have an instance of DCDevieData";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_instance = this;
|
2017-05-19 11:23:11 +02:00
|
|
|
memset(&data, 0, sizeof(data));
|
|
|
|
data.trip = nullptr;
|
|
|
|
data.download_table = nullptr;
|
|
|
|
data.diveid = 0;
|
|
|
|
data.deviceid = 0;
|
|
|
|
}
|
|
|
|
|
2017-06-05 19:41:57 -07:00
|
|
|
DCDeviceData *DCDeviceData::instance()
|
|
|
|
{
|
|
|
|
if (!m_instance)
|
|
|
|
m_instance = new DCDeviceData();
|
|
|
|
return m_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
|
|
|
|
{
|
|
|
|
return productList[vendor];
|
|
|
|
}
|
|
|
|
|
2017-05-26 16:40:50 +02:00
|
|
|
DCDeviceData * DownloadThread::data()
|
2017-05-19 11:23:11 +02:00
|
|
|
{
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
2017-05-12 19:18:20 +02:00
|
|
|
QString DCDeviceData::vendor() const
|
|
|
|
{
|
|
|
|
return data.vendor;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::product() const
|
|
|
|
{
|
|
|
|
return data.product;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::devName() const
|
|
|
|
{
|
|
|
|
return data.devname;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::descriptor() const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::bluetoothMode() const
|
|
|
|
{
|
|
|
|
return data.bluetooth_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::forceDownload() const
|
|
|
|
{
|
|
|
|
return data.force_download;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DCDeviceData::createNewTrip() const
|
|
|
|
{
|
|
|
|
return data.create_new_trip;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DCDeviceData::deviceId() const
|
|
|
|
{
|
|
|
|
return data.deviceid;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DCDeviceData::diveId() const
|
|
|
|
{
|
|
|
|
return data.diveid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setVendor(const QString& vendor)
|
|
|
|
{
|
|
|
|
data.vendor = strdup(qPrintable(vendor));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setProduct(const QString& product)
|
|
|
|
{
|
|
|
|
data.product = strdup(qPrintable(product));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setDevName(const QString& devName)
|
|
|
|
{
|
|
|
|
data.devname = strdup(qPrintable(devName));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setBluetoothMode(bool mode)
|
|
|
|
{
|
|
|
|
data.bluetooth_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setForceDownload(bool force)
|
|
|
|
{
|
|
|
|
data.force_download = force;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setCreateNewTrip(bool create)
|
|
|
|
{
|
|
|
|
data.create_new_trip = create;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setDeviceId(int deviceId)
|
|
|
|
{
|
|
|
|
data.deviceid = deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCDeviceData::setDiveId(int diveId)
|
|
|
|
{
|
|
|
|
data.diveid = diveId;
|
|
|
|
}
|
2017-05-19 11:23:11 +02: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_data_t* DCDeviceData::internalData()
|
|
|
|
{
|
|
|
|
return &data;
|
|
|
|
}
|
2017-06-05 19:41:57 -07:00
|
|
|
|
2017-06-10 10:09:56 +02:00
|
|
|
int DCDeviceData::getDetectedVendorIndex(const QString ¤tText)
|
2017-06-05 19:41:57 -07: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 10:38:24 +02:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 10:09:56 +02:00
|
|
|
|
|
|
|
// Pick the vendor of the first confirmed find of a DC (if any), but
|
2017-06-10 14:22:28 +02:00
|
|
|
// only return a true vendor, and not our virtual one
|
2017-06-10 10:09:56 +02:00
|
|
|
if (!btDCs.isEmpty() && currentText != QObject::tr("Paired Bluetooth Devices")) {
|
|
|
|
qDebug() << "getDetectedVendorIndex" << currentText << btDCs.first().vendorIdx;
|
2017-06-05 19:41:57 -07:00
|
|
|
return btDCs.first().vendorIdx;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-06-10 10:09:56 +02:00
|
|
|
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText,
|
|
|
|
const QString ¤tProductText)
|
2017-06-05 19:41:57 -07: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 10:38:24 +02:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 10:09:56 +02: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
|
|
|
|
// BT device
|
|
|
|
if (currentVendorText != QObject::tr("Paired Bluetooth Devices") && !btDCs.isEmpty()) {
|
2017-06-08 14:15:22 +02:00
|
|
|
qDebug() << "getDetectedProductIndex" << btDCs.first().productIdx;
|
2017-06-05 19:41:57 -07:00
|
|
|
return btDCs.first().productIdx;
|
|
|
|
}
|
2017-06-10 10:09:56 +02:00
|
|
|
|
|
|
|
// if the above fails, display the selected paired device
|
|
|
|
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
|
|
|
|
qDebug() << "getDetectedProductIndex" << productList[currentVendorText].indexOf(currentProductText);
|
|
|
|
return productList[currentVendorText].indexOf(currentProductText);
|
|
|
|
}
|
2017-06-05 19:41:57 -07:00
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-06-10 10:09:56 +02:00
|
|
|
QString DCDeviceData::getDetectedDeviceAddress(const QString ¤tVendorText,
|
|
|
|
const QString ¤tProductText)
|
2017-06-05 19:41:57 -07:00
|
|
|
{
|
2017-06-10 10:09:56 +02:00
|
|
|
#if defined(BT_SUPPORT)
|
|
|
|
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
|
2017-07-03 17:28:27 -07:00
|
|
|
// simply get the address from the product text
|
|
|
|
QRegularExpression extractAddr(".*\\(([0-9A-FL:]*)\\)");
|
|
|
|
QRegularExpressionMatch m = extractAddr.match(currentProductText);
|
|
|
|
if (m.hasMatch()) {
|
|
|
|
qDebug() << "matched" << m.captured(1);
|
|
|
|
return m.captured(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Otherwise, pull the vendor from the found devices that are possible real dive computers
|
|
|
|
// HACK: this assumes that dive computer names are unique across vendors
|
|
|
|
// and will only give you the first of multiple identically named dive computers - use
|
|
|
|
// the Paired Bluetooth Devices vendor in cases like that
|
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
|
|
|
BTDiscovery::btVendorProduct btDC;
|
|
|
|
Q_FOREACH(btDC, btDCs) {
|
|
|
|
if (currentProductText.startsWith(dc_descriptor_get_product(btDC.dcDescriptor)))
|
|
|
|
return btDC.btpdi.address;
|
2017-06-10 10:09:56 +02:00
|
|
|
}
|
2017-06-10 14:22:28 +02:00
|
|
|
#endif
|
2017-07-03 17:28:27 -07:00
|
|
|
return QStringLiteral("cannot determine address of dive computer");
|
2017-06-10 14:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::getDeviceDescriptorVendor(const QString ¤tVendorText,
|
|
|
|
const QString ¤tProductText)
|
|
|
|
{
|
|
|
|
#if defined(BT_SUPPORT)
|
2017-07-03 17:28:27 -07:00
|
|
|
if (currentVendorText != QObject::tr("Paired Bluetooth Devices"))
|
|
|
|
return currentVendorText;
|
2017-06-10 14:22:28 +02:00
|
|
|
|
2017-07-03 17:28:27 -07:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 14:22:28 +02:00
|
|
|
|
2017-07-03 17:28:27 -07:00
|
|
|
// Pull the vendor from the found devices that are possible real dive computers
|
|
|
|
// HACK: this assumes that dive computer names are unique across vendors
|
|
|
|
BTDiscovery::btVendorProduct btDC;
|
|
|
|
Q_FOREACH(btDC, btDCs) {
|
|
|
|
if (currentProductText.startsWith(dc_descriptor_get_product(btDC.dcDescriptor)))
|
|
|
|
return dc_descriptor_get_vendor(btDC.dcDescriptor);
|
2017-06-10 14:22:28 +02:00
|
|
|
}
|
|
|
|
#endif
|
2017-07-03 17:28:27 -07:00
|
|
|
return QStringLiteral("failed to detect vendor");
|
2017-06-10 14:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DCDeviceData::getDeviceDescriptorProduct(const QString ¤tVendorText,
|
|
|
|
const QString ¤tProductText)
|
|
|
|
{
|
|
|
|
#if defined(BT_SUPPORT)
|
2017-07-03 17:28:27 -07:00
|
|
|
if (currentVendorText != QObject::tr("Paired Bluetooth Devices"))
|
|
|
|
return currentProductText;
|
2017-06-10 14:22:28 +02:00
|
|
|
|
2017-07-03 17:28:27 -07:00
|
|
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
2017-06-10 14:22:28 +02:00
|
|
|
|
2017-07-03 17:28:27 -07:00
|
|
|
// Pull the canonical product from the found devices that are possible real dive computers
|
|
|
|
// HACK: this assumes that dive computer names are unique across vendors
|
|
|
|
BTDiscovery::btVendorProduct btDC;
|
|
|
|
Q_FOREACH(btDC, btDCs) {
|
|
|
|
if (currentProductText.startsWith(dc_descriptor_get_product(btDC.dcDescriptor)))
|
|
|
|
return dc_descriptor_get_product(btDC.dcDescriptor);
|
2017-06-10 14:22:28 +02:00
|
|
|
}
|
2017-06-05 19:41:57 -07:00
|
|
|
#endif
|
2017-07-03 17:28:27 -07:00
|
|
|
return QStringLiteral("failed to detect product");
|
2017-06-05 19:41:57 -07:00
|
|
|
}
|