From bec5f3c44f4c08a19700bce912c818c2d650a224 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 12 Jul 2017 04:13:25 -0700 Subject: BT support: track if Bluetooth is available Signed-off-by: Dirk Hohndel --- core/btdiscovery.cpp | 8 ++++++++ core/btdiscovery.h | 2 ++ 2 files changed, 10 insertions(+) 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::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 btDCs; // recognized DCs QList btAllDevices; // all paired BT stuff -- cgit v1.2.3-70-g09d2