diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2021-11-25 14:10:33 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-26 08:33:31 +0000 |
commit | 46302b85f642e57f8020db80c62f824beed44e4f (patch) | |
tree | 1a4f1a5b4742441019451e37a9243b8b00008bb1 | |
parent | 927f7122072264b23a3b245eb12107ba6ca958fd (diff) | |
download | qtconnectivity-46302b85f642e57f8020db80c62f824beed44e4f.tar.gz |
Fix handling of manufacturer data in Bluetooth advertisement parsing
There were two bugs in the handling of manufacturer data
when parsing advertisement packages:
First, not every call to onBluetoothLEAdvertisementReceived
contains manufacturer data. In the call where no manufacturer data
is given, data given earlier should not be deleted.
Second, manufacturer data was only processed when also data
about the services was present, which is sometimes not the case.
This patch fixes both bugs.
Change-Id: I3d0798e0a19dd7ade6476e2f9b37397094aebf60
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit e5c2e0ab6401663cecd96602d25b2070e144de41)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp index 789adba5..1aa0c6c9 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp @@ -362,8 +362,6 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEAdvertisementReceived QMutexLocker locker(&m_foundDevicesMutex); // Merge newly found services with list of currently found ones if (m_foundLEDevicesMap.contains(address)) { - if (size == 0) - return S_OK; const LEAdvertisingInfo adInfo = m_foundLEDevicesMap.value(address); QList<QBluetoothUuid> foundServices = adInfo.services; if (adInfo.rssi != rssi) { @@ -371,8 +369,9 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEAdvertisementReceived changedFields.setFlag(QBluetoothDeviceInfo::Field::RSSI); } if (adInfo.manufacturerData != manufacturerData) { - m_foundLEDevicesMap[address].manufacturerData = std::move(manufacturerData); - changedFields.setFlag(QBluetoothDeviceInfo::Field::ManufacturerData); + m_foundLEDevicesMap[address].manufacturerData.insert(manufacturerData); + if (adInfo.manufacturerData != m_foundLEDevicesMap[address].manufacturerData) + changedFields.setFlag(QBluetoothDeviceInfo::Field::ManufacturerData); } bool newServiceAdded = false; for (const QBluetoothUuid &uuid : qAsConst(serviceUuids)) { |