mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: add BT name to vendor/product capability
This adds a central function to convert a BT name to a vendor/product pair known to Subsurface. This allows interfacing from a paired BT dive computer, without actively selecting its type, but by selecting it from the list of paired BT devices. So, after this, downloading from multiple (paired) DCs is also possible. And not the niced piece of code ... Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a43cafa515
commit
5142d7409f
5 changed files with 109 additions and 8 deletions
|
@ -249,7 +249,7 @@ int DCDeviceData::getDetectedVendorIndex(const QString ¤tText)
|
|||
QList<btVendorProduct> btAllDevices = BTDiscovery::instance()->getBtAllDevices();
|
||||
|
||||
// Pick the vendor of the first confirmed find of a DC (if any), but
|
||||
// only return a true vendow, and not our virtual one
|
||||
// only return a true vendor, and not our virtual one
|
||||
if (!btDCs.isEmpty() && currentText != QObject::tr("Paired Bluetooth Devices")) {
|
||||
qDebug() << "getDetectedVendorIndex" << currentText << btDCs.first().vendorIdx;
|
||||
return btDCs.first().vendorIdx;
|
||||
|
@ -311,7 +311,62 @@ QString DCDeviceData::getDetectedDeviceAddress(const QString ¤tVendorText,
|
|||
qDebug() << "getDetectedDeviceAddress" << btAddr;
|
||||
return btAddr;
|
||||
}
|
||||
|
||||
return QString();
|
||||
#endif
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DCDeviceData::getDeviceDescriptorVendor(const QString ¤tVendorText,
|
||||
const QString ¤tProductText)
|
||||
{
|
||||
#if defined(BT_SUPPORT)
|
||||
QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
||||
QList<btVendorProduct> btAllDevices = BTDiscovery::instance()->getBtAllDevices();
|
||||
|
||||
// Pull the vendor from 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()) {
|
||||
QString dcVendor = dc_descriptor_get_vendor(btDCs.first().dcDescriptor);
|
||||
qDebug() << "getDeviceDescriptorVendor" << dcVendor;
|
||||
return dcVendor;
|
||||
}
|
||||
|
||||
// if the above fails, pull vendor from the selected paired device
|
||||
// unsure being a dive computer
|
||||
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
|
||||
int i = productList[currentVendorText].indexOf(currentProductText);
|
||||
QString dcVendor = dc_descriptor_get_vendor(btAllDevices[i].dcDescriptor);
|
||||
qDebug() << "getDeviceDescriptorVendor" << dcVendor;
|
||||
return dcVendor;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QString DCDeviceData::getDeviceDescriptorProduct(const QString ¤tVendorText,
|
||||
const QString ¤tProductText)
|
||||
{
|
||||
#if defined(BT_SUPPORT)
|
||||
QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
||||
QList<btVendorProduct> btAllDevices = BTDiscovery::instance()->getBtAllDevices();
|
||||
|
||||
// Pull the product from 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()) {
|
||||
QString dcProduct = dc_descriptor_get_product(btDCs.first().dcDescriptor);
|
||||
qDebug() << "getDeviceDescriptorProduct" << dcProduct;
|
||||
return dcProduct;
|
||||
}
|
||||
|
||||
// if the above fails, pull product from the selected paired device
|
||||
// unsure being a dive computer
|
||||
if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) {
|
||||
int i = productList[currentVendorText].indexOf(currentProductText);
|
||||
QString dcProduct = dc_descriptor_get_product(btAllDevices[i].dcDescriptor);
|
||||
qDebug() << "getDeviceDescriptorProduct" << dcProduct;
|
||||
return dcProduct;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue