From 6c3fde845d391e86003ff87371e2d4174b8212dc Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 6 Aug 2019 14:29:38 +0200 Subject: Modify point when lowenergyscanner remembers found BTLE devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: André de la Rocha --- examples/bluetooth/lowenergyscanner/device.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'examples/bluetooth/lowenergyscanner') 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 foundDevices = discoveryAgent->discoveredDevices(); + for (auto nextDevice : foundDevices) + if (nextDevice.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) + devices.append(new DeviceInfo(nextDevice)); + emit devicesUpdated(); m_deviceScanState = false; emit stateChanged(); -- cgit v1.2.3