summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-25 20:04:02 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-12 08:22:44 -0700
commit9491c96103d7be26e3a98245a345adcb9230c035 (patch)
tree03a3746b116928081a1ee8cad0dd5a0697c25a03
parent2954bc5f222ff3808a2b51be4a6f1c13f6ca8944 (diff)
downloadsubsurface-9491c96103d7be26e3a98245a345adcb9230c035.tar.gz
Bluetooth: start discovery if address isn't already known
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/btdiscovery.cpp7
-rw-r--r--core/btdiscovery.h1
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp1
3 files changed, 9 insertions, 0 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index e4c17902e..c3f6c9b36 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -301,6 +301,13 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob
}
#endif // Q_OS_ANDROID
+void BTDiscovery::discoverAddress(QString address)
+{
+ if (!btDeviceInfo.keys().contains(address) && !discoveryAgent->isActive()) {
+ qDebug() << "restarting discovery agent";
+ discoveryAgent->start();
+ }
+}
bool isBluetoothAddress(const QString &address)
{
diff --git a/core/btdiscovery.h b/core/btdiscovery.h
index beabdf122..17790e30c 100644
--- a/core/btdiscovery.h
+++ b/core/btdiscovery.h
@@ -49,6 +49,7 @@ public:
QList<btVendorProduct> getBtDcs();
QBluetoothLocalDevice localBtDevice;
void BTDiscoveryReDiscover();
+ void discoverAddress(QString address);
private:
static BTDiscovery *m_instance;
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 509d3b402..b0687bb3a 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -311,6 +311,7 @@ void DownloadFromDCWidget::on_device_currentTextChanged(const QString &device)
// ensure we have a discovery running
if (btd == nullptr)
btd = BTDiscovery::instance();
+ btd->discoverAddress(device);
}
#else
Q_UNUSED(device)