aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-12 04:13:25 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-12 04:13:25 -0700
commitbec5f3c44f4c08a19700bce912c818c2d650a224 (patch)
tree4a1734295bcba7388b265a07958119a285ed849d /core
parent0c5f373ec0f40d1e89686c1d59bc113739ff2bc9 (diff)
downloadsubsurface-bec5f3c44f4c08a19700bce912c818c2d650a224.tar.gz
BT support: track if Bluetooth is available
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/btdiscovery.cpp8
-rw-r--r--core/btdiscovery.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index a59bb5ccd..71d6353c5 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -61,6 +61,7 @@ BTDiscovery::BTDiscovery(QObject *parent)
localBtDevice.hostMode() == QBluetoothLocalDevice::HostConnectable) {
btPairedDevices.clear();
qDebug() << "localDevice " + localBtDevice.name() + " is valid, starting discovery";
+ m_btValid = true;
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered);
@@ -84,6 +85,7 @@ BTDiscovery::BTDiscovery(QObject *parent)
#endif
} else {
qDebug() << "localBtDevice isn't valid";
+ m_btValid = false;
}
#endif
}
@@ -175,6 +177,12 @@ QList<BTDiscovery::btVendorProduct> BTDiscovery::getBtDcs()
return btDCs;
}
+bool BTDiscovery::btAvailable() const
+{
+ return m_btValid;
+
+}
+
// Android: As Qt is not able to pull the pairing data from a device, i
// a lengthy discovery process is needed to see what devices are paired. On
// https://forum.qt.io/topic/46075/solved-bluetooth-list-paired-devices
diff --git a/core/btdiscovery.h b/core/btdiscovery.h
index 1432df260..4b4e4b802 100644
--- a/core/btdiscovery.h
+++ b/core/btdiscovery.h
@@ -40,6 +40,7 @@ public:
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
void btDeviceDiscoveredMain(const btPairedDevice &device);
+ bool btAvailable() const;
#if defined(Q_OS_ANDROID)
void getBluetoothDevices();
#endif
@@ -47,6 +48,7 @@ public:
#endif
private:
static BTDiscovery *m_instance;
+ bool m_btValid;
#if defined(BT_SUPPORT)
QList<struct btVendorProduct> btDCs; // recognized DCs
QList<struct btVendorProduct> btAllDevices; // all paired BT stuff