diff options
Diffstat (limited to 'examples/bluetooth/lowenergyscanner')
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.cpp | 12 |
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(); |