diff options
Diffstat (limited to 'tests/bttestui')
-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 8c85599f..a14709ee 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -49,6 +49,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) { @@ -87,7 +90,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)), @@ -96,7 +99,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)), @@ -537,16 +540,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(); |