diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-09-29 14:58:13 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-30 16:40:41 -0700 |
commit | 4608beaee4176214aa13d561f6694376f400be8a (patch) | |
tree | 0c7676be3b426a3ea9c4de46792d48ab83451139 /core | |
parent | 5b485850925cc77c827b3e46d6f2236fe3329d7a (diff) | |
download | subsurface-4608beaee4176214aa13d561f6694376f400be8a.tar.gz |
Android BLE discovery: use discovery agent
Android can't scan for classic BT devices, so when BT support was first
added, we simply didn't use the discovery agent at all and relied on the
list of paired BT devices provided by Android.
This still worked fine for a lot of BLE devices that allowed 'bonding'
with the Android device - similar to pairing. But some BLE devices (like
the Shearwater Peregrine) don't support bonding and so our Android code
didn't see them at all.
With this commit we start a BLE only scan on Android to add to the list
of already paired devices.
Fixes: #2974
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/btdiscovery.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 6538ba117..73a0ab803 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -181,7 +181,7 @@ void BTDiscovery::BTDiscoveryReDiscover() if (1) { #endif m_btValid = true; -#if !defined(Q_OS_ANDROID) + if (discoveryAgent == nullptr) { discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); discoveryAgent->setLowEnergyDiscoveryTimeout(3 * 60 * 1000); // search for three minutes @@ -194,18 +194,22 @@ void BTDiscovery::BTDiscoveryReDiscover() }); qDebug() << "discovery methods" << (int)QBluetoothDeviceDiscoveryAgent::supportedDiscoveryMethods(); } +#if defined(Q_OS_ANDROID) + // on Android, we cannot scan for classic devices - we just get the paired ones qDebug() << "starting BLE discovery"; - discoveryAgent->start(); -#else + discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); 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++) btDeviceDiscoveredMain(btPairedDevices[i], true); -#endif +#else + qDebug() << "starting BT/BLE discovery"; + discoveryAgent->start(); for (int i = 0; i < btPairedDevices.length(); i++) qDebug() << "Paired =" << btPairedDevices[i].name << btPairedDevices[i].address; +#endif #if defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) QTimer timer; |