diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-09-24 17:28:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-12 08:22:44 -0700 |
commit | 2ba3eab31978b6dd5956f0af7749549ba724e300 (patch) | |
tree | d4062d9d1f2a560986876c0bcfcb8f332d8e4605 /core | |
parent | c6b62cbe5c4662984f1a3650e4913fe0e9b9383b (diff) | |
download | subsurface-2ba3eab31978b6dd5956f0af7749549ba724e300.tar.gz |
Bluetooth: discovery should always scan on macOS as well
Instead of only starting the scan when explicitly asked to do so in the BT
dialog, create the discovery agent when the download dialog opens, since on
macOS we cannot connect to a device without having scanned for it first.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/btdiscovery.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 1527be624..77a3dd3a5 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -71,7 +71,7 @@ static dc_descriptor_t *getDeviceType(QString btName) } BTDiscovery::BTDiscovery(QObject*) : m_btValid(false), - discoveryAgent(NULL) + discoveryAgent(nullptr) { if (m_instance) { qDebug() << "trying to create an additional BTDiscovery object"; @@ -98,25 +98,24 @@ void BTDiscovery::BTDiscoveryReDiscover() if (1) { #endif m_btValid = true; -#if defined(Q_OS_WIN) || defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); - connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered); +#if !defined(Q_OS_ANDROID) + if (discoveryAgent == nullptr) { + discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); + connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered); + } qDebug() << "starting BLE discovery"; discoveryAgent->start(); -#endif -#if defined(Q_OS_ANDROID) +#else getBluetoothDevices(); // and add the paired devices to the internal data // So behaviour is same on Linux/Bluez stack and // Android/Java stack with respect to discovery - for (int i = 0; i < btPairedDevices.length(); i++) { + for (int i = 0; i < btPairedDevices.length(); i++) btDeviceDiscoveredMain(btPairedDevices[i]); - - } #endif - for (int i = 0; i < btPairedDevices.length(); i++) { + for (int i = 0; i < btPairedDevices.length(); i++) qDebug() << "Paired =" << btPairedDevices[i].name << btPairedDevices[i].address; - } + #if defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) QTimer timer; timer.setSingleShot(true); |