diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2016-12-07 08:58:09 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2016-12-07 08:03:48 +0000 |
commit | 1750983d3f053316c735d602c7f9a1b56dc4462b (patch) | |
tree | 535083208486ebde5d2e4e7ec317b5daa160f39d /examples | |
parent | d7eda19aaf1c346cfd60b52da26fea6001fc35bd (diff) |
Restrict the BTLE examples to Low Energy use cases
This change vastely descreases the search time. There is no need to
perform a traditional SDP scan too.
Change-Id: I63d7e16dca77fb1b1db42bb330f91e917a9dd054
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bluetooth/heartlistener/heartrate.cpp | 3 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp index 7077bf1c..c206b69e 100644 --- a/examples/bluetooth/heartlistener/heartrate.cpp +++ b/examples/bluetooth/heartlistener/heartrate.cpp @@ -50,6 +50,7 @@ HeartRate::HeartRate(): { //! [devicediscovery-1] m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); + m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(5000); connect(m_deviceDiscoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(addDevice(const QBluetoothDeviceInfo&))); @@ -73,7 +74,7 @@ void HeartRate::deviceSearch() qDeleteAll(m_devices); m_devices.clear(); //! [devicediscovery-2] - m_deviceDiscoveryAgent->start(); + m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); //! [devicediscovery-2] setMessage("Scanning for devices..."); } diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 5ef2cf76..28a051f5 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -54,6 +54,7 @@ Device::Device(): { //! [les-devicediscovery-1] discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); + discoveryAgent->setLowEnergyDiscoveryTimeout(5000); connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(addDevice(const QBluetoothDeviceInfo&))); connect(discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), @@ -84,7 +85,7 @@ void Device::startDeviceDiscovery() setUpdate("Scanning for devices ..."); //! [les-devicediscovery-2] - discoveryAgent->start(); + discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); //! [les-devicediscovery-2] if (discoveryAgent->isActive()) { |