summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner/device.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2019-08-06 14:29:38 +0200
committerAlex Blasche <alexander.blasche@qt.io>2019-08-07 08:46:26 +0200
commit6c3fde845d391e86003ff87371e2d4174b8212dc (patch)
treee4d0df09962eb79d55ffb948e180381fc8793cfb /examples/bluetooth/lowenergyscanner/device.cpp
parentf2f9da656fd77330cce44dfe0721b3f68f1d809d (diff)
Modify point when lowenergyscanner remembers found BTLE devices
Technically speaking, nothing really changes in the application. However devices found, when QBluetoothDeviceInfo::deviceDiscovered() is emitted, may not have the complete set of data for a given device. In particular, rssi and manufacturer data changes happen later. Later changes to the example may want to display these transient types of information at which point this change becomes essential. It makes the app simpler to adopt for testing purposes too. Change-Id: I119b6e80a9a92b16de2d3e6792132ceb06b577a4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Diffstat (limited to 'examples/bluetooth/lowenergyscanner/device.cpp')
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index d860457e..e1d96be3 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -108,16 +108,18 @@ void Device::startDeviceDiscovery()
//! [les-devicediscovery-3]
void Device::addDevice(const QBluetoothDeviceInfo &info)
{
- if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
- auto d = new DeviceInfo(info);
- devices.append(d);
- setUpdate("Last device added: " + d->getName());
- }
+ if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
+ setUpdate("Last device added: " + info.name());
}
//! [les-devicediscovery-3]
void Device::deviceScanFinished()
{
+ const QList<QBluetoothDeviceInfo> foundDevices = discoveryAgent->discoveredDevices();
+ for (auto nextDevice : foundDevices)
+ if (nextDevice.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
+ devices.append(new DeviceInfo(nextDevice));
+
emit devicesUpdated();
m_deviceScanState = false;
emit stateChanged();