aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qmlmanager.cpp32
-rw-r--r--mobile-widgets/qmlmanager.h9
2 files changed, 41 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.
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 16085dc44..0d7f2aaa0 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -10,6 +10,7 @@
#if BT_SUPPORT
#include <QBluetoothLocalDevice>
#include <QBluetoothDeviceDiscoveryAgent>
+#include <QBluetoothUuid>
#endif
#include "core/gpslocation.h"
@@ -118,6 +119,8 @@ public:
bool showPin() const;
void setShowPin(bool enable);
Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
+ Q_INVOKABLE int getVendorIndex();
+ Q_INVOKABLE int getProductIndex();
#if BT_SUPPORT
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
#endif
@@ -206,6 +209,12 @@ private:
#if BT_SUPPORT
QBluetoothLocalDevice localBtDevice;
QBluetoothDeviceDiscoveryAgent *discoveryAgent;
+ struct btVendorProduct {
+ QBluetoothDeviceInfo btdi;
+ int vendorIdx;
+ int productIdx;
+ };
+ QList<struct btVendorProduct> btDCs;
#endif
signals: