From b5ec1e15f360cd60386488588dd4796169082355 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 10 May 2019 11:17:21 +0200 Subject: winrt: Make sure that ProtocolDescriptorList is always set for services For some devices the attribute map does not have a protocol descriptor set which throws off Qt's logic. As Windows can only discover RFCOMM services, we can just add that protocol to the service ourselves if it is not found automatically. Task-number: QTBUG-62520 Change-Id: I6ce3948892699049b678b026840d346879b98269 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp index 3b99c1c4..f1476758 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp @@ -336,6 +336,17 @@ void QWinRTBluetoothServiceDiscoveryWorker::processServiceSearchResult(quint64 a } hr = iterator->MoveNext(¤t); } + // Windows is only able to discover Rfcomm services but the according protocolDescriptor is + // not always set in the raw attribute map. If we encounter a service like that we should + // fill the protocol descriptor ourselves. + if (info.protocolDescriptor(QBluetoothUuid::Rfcomm).isEmpty()) { + QBluetoothServiceInfo::Sequence protocolDescriptorList; + QBluetoothServiceInfo::Sequence protocol; + protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) + << QVariant::fromValue(0); + protocolDescriptorList.append(QVariant::fromValue(protocol)); + info.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList); + } emit serviceFound(address, info); } emit scanFinished(address); -- cgit v1.2.3