summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-09 15:58:23 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-15 11:57:26 +0000
commitc37703dcfcd6c9762be046779f136bc8f1c4acd9 (patch)
tree01f487d407171b61e422d17968ddbec8837408a6 /src/bluetooth/qbluetoothdevicediscoveryagent.cpp
parentdb55878a269450d7a8f559e5d3862403eba7fbc8 (diff)
Add BTLE device discovery timeout API
This timeout adjusts the BTLE device discovery. Some BTLE devices require some time to show up in such a search. In general the platforms use open ended search methodologies as their own usage pattern for BTLE device discovery too. So far Qt Bluetooth limited the time through a hardcoded value which the API user could not adjust. Task-number: QTBUG-53012 Change-Id: Ia37cebd4015b438db998c6b4a265f563c1a2f89f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent.cpp')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index b6faee75..b90f6b01 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -232,6 +232,49 @@ QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent::discoveredDevices()
}
/*!
+ Sets the maximum search time for Bluetooth Low Energy device search to
+ \a timeout in milliseconds. If \a timeout is \c 0 the discovery runs
+ until \l stop() is called.
+
+ This reflects the fact that the discovery process for Bluetooth Low Energy devices
+ is mostly open ended. The platform continues to look for more devices until the search is
+ manually stopped. The timeout ensures that the search is aborted after \a timeout milliseconds.
+ Of course, it is still possible to manually abort the discovery by calling \l stop().
+
+ The new timeout value does not take effect until the device search is restarted.
+ In addition the timeout does not affect the classic Bluetooth device search. Depending on
+ the platform it may add more time to the total discovery process beyond \a timeout.
+
+ \a lowEnergyDiscoveryTimeout()
+ \since 5.8
+ */
+void QBluetoothDeviceDiscoveryAgent::setLowEnergyDiscoveryTimeout(int timeout)
+{
+ Q_D(QBluetoothDeviceDiscoveryAgent);
+
+ // cannot deliberately turn it off
+ if (d->lowEnergySearchTimeout < 0 || timeout < 0)
+ return;
+
+ d->lowEnergySearchTimeout = timeout;
+}
+
+/*!
+ Returns a timeout in milliseconds that is applied to the Bluetooth Low Energy device search.
+ A value of \c -1 implies that the platform does not support this property and the timeout for
+ the device search cannot be adjusted. A return value of \c 0
+ implies a never-ending search which must be manually stopped via \l stop().
+
+ \sa setLowEnergyDiscoveryTimeout()
+ \since 5.8
+ */
+int QBluetoothDeviceDiscoveryAgent::lowEnergyDiscoveryTimeout() const
+{
+ Q_D(const QBluetoothDeviceDiscoveryAgent);
+ return d->lowEnergySearchTimeout;
+}
+
+/*!
Starts Bluetooth device discovery, if it is not already started.
The deviceDiscovered() signal is emitted as each device is discovered. The finished() signal