summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2016-08-08 10:47:21 +0200
committerOliver Wolff <oliver.wolff@qt.io>2016-08-09 06:57:54 +0000
commit971c898235d3f48a6b33a17359cd3d644b9f8b5f (patch)
tree02e9c8acfa149c6d7f44e6b5f92bf89c7eda67c9 /src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
parentefaa9711183b1a7d518baa89fa74cbe5606a073a (diff)
winrt: Filter devices found by the LE device watcher
It is possible that devices are found by the initial scan and by the device watcher. In this cases the "device found" signal should not be emitted. Change-Id: Ic8aa5a088092adfa8a5b2ea5a3c91350a7897e6a Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 674302bf..ec8de3e8 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -365,7 +365,6 @@ QBluetoothDeviceDiscoveryAgent::DiscoveryMethods QBluetoothDeviceDiscoveryAgent:
void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods methods)
{
- Q_Q(QBluetoothDeviceDiscoveryAgent);
if (worker)
return;
@@ -378,12 +377,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent
discoveredDevices.clear();
connect(worker, &QWinRTBluetoothDeviceDiscoveryWorker::initializationCompleted,
this, &QBluetoothDeviceDiscoveryAgentPrivate::onListInitializationCompleted);
+ connect(worker, &QWinRTBluetoothDeviceDiscoveryWorker::leDeviceFound,
+ this, &QBluetoothDeviceDiscoveryAgentPrivate::onLeDeviceFound);
connect(worker, &QWinRTBluetoothDeviceDiscoveryWorker::scanFinished,
this, &QBluetoothDeviceDiscoveryAgentPrivate::onScanFinished);
connect(worker, &QWinRTBluetoothDeviceDiscoveryWorker::scanCanceled,
this, &QBluetoothDeviceDiscoveryAgentPrivate::onScanCanceled);
- connect(worker, &QWinRTBluetoothDeviceDiscoveryWorker::leDeviceFound,
- q, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered);
worker->start();
if (lowEnergySearchTimeout > 0 && methods & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod) { // otherwise no timeout and stop() required
@@ -417,6 +416,17 @@ void QBluetoothDeviceDiscoveryAgentPrivate::onListInitializationCompleted()
emit q->deviceDiscovered(info);
}
+void QBluetoothDeviceDiscoveryAgentPrivate::onLeDeviceFound(const QBluetoothDeviceInfo &info)
+{
+ Q_Q(QBluetoothDeviceDiscoveryAgent);
+ for (auto discoveredInfo : discoveredDevices)
+ if (discoveredInfo.address() == info.address())
+ return;
+
+ discoveredDevices << info;
+ emit q->deviceDiscovered(info);
+}
+
void QBluetoothDeviceDiscoveryAgentPrivate::onScanFinished()
{
Q_Q(QBluetoothDeviceDiscoveryAgent);