aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 15:07:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 15:08:28 -0700
commit18eff8f2b39bb304908c28b08b124cb7bb48a6ed (patch)
tree1f45e1510bf9d18adc522911606e97a41a4f513c /mobile-widgets/qmlmanager.cpp
parent5c4f9986fe6f830fef37379bae35599a5427b9c0 (diff)
downloadsubsurface-18eff8f2b39bb304908c28b08b124cb7bb48a6ed.tar.gz
QML UI: detect BT dive computers
If we find something that looks like a known BT dive computer, set things up so that we can use it later. If multiple dive computers are found, simply use the first. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 510866137..d9ec7c1c8 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -207,16 +207,48 @@ void QMLManager::mergeLocalRepo()
void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
QString newDevice = device.name();
+ QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
+ foreach (QBluetoothUuid id, serviceUuids) {
+ qDebug() << id.toByteArray();
+ }
appendTextToLog("Found new device " + newDevice + " (" + device.address().toString() + ")");
QString vendor, product;
foreach (vendor, productList.keys()) {
if (productList[vendor].contains(newDevice)) {
appendTextToLog("this could be a " + vendor + " " + newDevice);
+ struct btVendorProduct btVP;
+ btVP.btdi = device;
+ btVP.vendorIdx = vendorList.indexOf(vendor);
+ btVP.productIdx = productList[vendor].indexOf(newDevice);
+ qDebug() << "adding new btDCs entry" << newDevice << btVP.vendorIdx << btVP.productIdx;
+ btDCs << btVP;
}
}
}
#endif
+int QMLManager::getVendorIndex()
+{
+#if BT_SUPPORT
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getVendorIdx" << btDCs.first().vendorIdx;
+ return btDCs.first().vendorIdx;
+ }
+#endif
+ return -1;
+}
+
+int QMLManager::getProductIndex()
+{
+#if BT_SUPPORT
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getProductIdx" << btDCs.first().productIdx;
+ return btDCs.first().productIdx;
+ }
+#endif
+ return -1;
+}
+
void QMLManager::finishSetup()
{
// Initialize cloud credentials.