diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-28 16:22:31 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-28 16:22:31 +0200 |
commit | 8146a18be0c98751816ffe40661308081a57573d (patch) | |
tree | 69a2ddc07bad88df0d27d6b9a33ebb1ac522b71a /tests/bttestui/btlocaldevice.cpp | |
parent | 9f4c45b58b82b59740dc60e22cba6894efd6c164 (diff) | |
parent | 167faeec86ed4d9c9f099f5180784c7b0cb9aa42 (diff) |
Merge remote-tracking branch 'origin/5.3' into 5.4
Conflicts:
src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
Change-Id: Ie8bf1903f9c7c1ccd5b05a3f97049ae0882b88b8
Diffstat (limited to 'tests/bttestui/btlocaldevice.cpp')
-rw-r--r-- | tests/bttestui/btlocaldevice.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index 2f7725c4..247c00e6 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -41,6 +41,9 @@ //same uuid as examples/bluetooth/btchat #define TEST_SERVICE_UUID "e8e10f95-1a70-4b27-9ccf-02010264e9c8" +#define SOCKET_PROTOCOL QBluetoothServiceInfo::RfcommProtocol +//#define SOCKET_PROTOCOL QBluetoothServiceInfo::L2capProtocol + BtLocalDevice::BtLocalDevice(QObject *parent) : QObject(parent) { @@ -81,7 +84,7 @@ BtLocalDevice::BtLocalDevice(QObject *parent) : connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error))); - socket = new QBluetoothSocket(this); + socket = new QBluetoothSocket(SOCKET_PROTOCOL, this); connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socketStateChanged(QBluetoothSocket::SocketState))); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), @@ -90,7 +93,7 @@ BtLocalDevice::BtLocalDevice(QObject *parent) : connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(readData())); - server = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); + server = new QBluetoothServer(SOCKET_PROTOCOL, this); server->setSecurityFlags(QBluetooth::NoSecurity); connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); connect(server, SIGNAL(error(QBluetoothServer::Error)), @@ -550,16 +553,21 @@ void BtLocalDevice::serverListenPort() QBluetoothServiceInfo::Sequence protocolDescriptorList; QBluetoothServiceInfo::Sequence protocol; protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap)); + if (server->serverType() == QBluetoothServiceInfo::L2capProtocol) + protocol << QVariant::fromValue(server->serverPort()); protocolDescriptorList.append(QVariant::fromValue(protocol)); - protocol.clear(); - protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) - << QVariant::fromValue(quint8(server->serverPort())); - protocolDescriptorList.append(QVariant::fromValue(protocol)); + + if (server->serverType() == QBluetoothServiceInfo::RfcommProtocol) { + protocol.clear(); + protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) + << QVariant::fromValue(quint8(server->serverPort())); + protocolDescriptorList.append(QVariant::fromValue(protocol)); + } serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList); //Register service - qDebug() << "###### Registering service on" << localDevice->address().toString(); + qDebug() << "###### Registering service on" << localDevice->address().toString() << server->serverPort(); bool result = serviceInfo.registerService(localDevice->address()); if (!result) { server->close(); |