diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp index 683dfb94e3762f72c543a5bcf8619a07321a66cb..d078a32c88a482a46ef8ffa8f0e5f9ff82017737 100644 --- a/examples/bluetooth/btchat/chatserver.cpp +++ b/examples/bluetooth/btchat/chatserver.cpp @@ -85,13 +85,17 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter) //serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010); + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; - classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); + profileSequence); - classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid))); + classId.clear(); + classId << QVariant::fromValue(QBluetoothUuid(serviceUuid)); + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); diff --git a/src/bluetooth/qbluetoothserver.cpp b/src/bluetooth/qbluetoothserver.cpp index d9e42adfa5e1aef37258bc708250280e6e6ffedd..8f760eed17f6dd981df9b2663f3c96478b3886d0 100644 --- a/src/bluetooth/qbluetoothserver.cpp +++ b/src/bluetooth/qbluetoothserver.cpp @@ -217,13 +217,18 @@ QBluetoothServiceInfo QBluetoothServer::listen(const QBluetoothUuid &uuid, const serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, browseSequence); + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); + profileSequence); + classId.clear(); //Android requires custom uuid to be set as service class - classId.prepend(QVariant::fromValue(uuid)); + classId << QVariant::fromValue(uuid); + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); serviceInfo.setServiceUuid(uuid); diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_osx.mm index d7f29ed35640d0b5652d291109c52f55de857760..a67684325e3f452036749cb0a61538d9fb40f2f9 100644 --- a/src/bluetooth/qbluetoothserver_osx.mm +++ b/src/bluetooth/qbluetoothserver_osx.mm @@ -380,11 +380,16 @@ QBluetoothServiceInfo QBluetoothServer::listen(const QBluetoothUuid &uuid, const serviceInfo.setAttribute(QSInfo::BrowseGroupList, QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); + QSInfo::Sequence profileSequence; QSInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); - serviceInfo.setAttribute(QSInfo::BluetoothProfileDescriptorList, classId); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); + serviceInfo.setAttribute(QSInfo::BluetoothProfileDescriptorList, profileSequence); - classId.prepend(QVariant::fromValue(uuid)); + classId.clear(); + classId << QVariant::fromValue(uuid); + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); serviceInfo.setAttribute(QSInfo::ServiceClassIds, classId); serviceInfo.setServiceUuid(uuid); diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index ac2b1906763b20b176cadb6ac95cf3724419ca91..f8201c86a1f72d355b5b0d789c64027ff6604d6c 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -370,12 +370,18 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB << QVariant::fromValue(0); protocolDescriptorList.append(QVariant::fromValue(protocol)); - //set SPP service class uuid + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); - classId.prepend(QVariant::fromValue(uuids.at(i))); + profileSequence); + + classId.clear(); + //set SPP service class uuid + classId << QVariant::fromValue(uuids.at(i)); + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Serial Port Profile")); @@ -387,10 +393,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB << QVariant::fromValue(0); protocolDescriptorList.append(QVariant::fromValue(protocol)); + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); + profileSequence); //also we need to set the custom uuid to the SPP uuid //otherwise QBluetoothSocket::connectToService() would fail due to a missing service uuid diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 25764703d49963c2ba277ccc30b855b365ec7784..9bac6791cd2a5c77cbd724ed40a2e942101add4f 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -289,11 +289,13 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryAdapters() serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); - serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); + profileSequence); serviceInfo.setServiceUuid(uuid); diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index 3f0ebdafe5ad93f12bdfa62687331392ca2d1d3b..d7590b706fd66ce18855842c756118ff35f819cc 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -576,12 +576,17 @@ void BtLocalDevice::serverListenPort() if (!ret) return; + QBluetoothServiceInfo::Sequence profileSequence; QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + classId << QVariant::fromValue(quint16(0x100)); + profileSequence.append(QVariant::fromValue(classId)); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, - classId); + profileSequence); - classId.prepend(QVariant::fromValue(QBluetoothUuid(QString(TEST_SERVICE_UUID)))); + classId.clear(); + classId << QVariant::fromValue(QBluetoothUuid(QString(TEST_SERVICE_UUID))); + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); // Service name, description and provider