[Interest] Qt Bluetooth in Linux non-functional?

Blasche Alexander Alexander.Blasche at digia.com
Fri Apr 25 09:00:40 CEST 2014


>________________________________________
>From: interest-bounces+alexander.blasche=digia.com at qt-project.org [interest-
>bounces+alexander.blasche=digia.com at qt-project.org] 
>on behalf of Alexander Zakharov 
>Subject: [Interest] Qt Bluetooth in Linux non-functional?

...
>data with it. Mac OS X is also running in a virtual machine on the
>same host, so there seems to be no issues with Bluetooth support in
>VMs.

QtBluetooth should work too. I am using it from within multiple VM's as well.

>The device itself can be discovered using
>QBluetoothDeviceDiscoveryAgent and corresponding QBluetoothDeviceInfo
>object can be obtained. However, service discovery in Qt does not work
>for the device. I have tried to use QBluetoothServiceDiscoveryAgent
>myself and have also run BTScanner example - there are no listed
>services. At the same time, when I run 'bluez-test-device discover
><device ID>' command from terminal, it correctly lists all services.

That is strange indeed. A failing service discovery.


>Since I have no QBluetoothServiceInfo object for the RFCOMM service of
>the device, but I know its UUID (it is used in both Windows and Mac OS
>X programs and is also printed in the output of bluez-test-device
>command), I have tried to create a socket in the following way:

>QBluetoothSocket* socket = new
>QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
>connect(socket, SIGNAL(connected()), this, SLOT(connected()));
>connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this,
>SLOT(error(QBluetoothSocket::SocketError)));
>socket->connectToService(device.address(),
>QBluetoothUuid(QString("00001101-0000-1000-8000-00805f9b34fb")));

>As a result, the error slot is called, with
>QBluetoothSocket::ServiceNotFoundError.

This would be the way to do it. However since you are connecting via uuid the socket in turn will do a service discovery once again because it must detect the port number for your service. The error code above indicates that exactly this SDP discovery is failing.

>The documentation about Bluetooth in Qt is very scant and I may be
>using QtBluetooth incorrectly, but the case when BTScanner is not
>working while 'bluez-test-device' command does is worrisome. Do you
>have any suggestions?

Do you have any chance to test the latest RC candidate? There were lots of bug fixes for QtBluetooth (over 30 just for Bluez 4):

https://qt.gitorious.org/qt/qtconnectivity/source/9b11226f3d23dfb4c6b8457f2a839584666cda6a:dist/changes-5.3.0

Most of them would have gone into Qt 5.2.2 if it would have been released. As it stands now they have moved into 5.3. 

Another reason why I'd like to ask you to use the 5.3 code line is because it has tracing capabilities. It can tell much more details on what might be happening. I would like to ask you to add the trace activation code to your main() function as can be seen in 

https://qt.gitorious.org/qt/qtconnectivity/source/9b11226f3d23dfb4c6b8457f2a839584666cda6a:tests/bttestui/main.cpp

The actual line is:
 QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));

Then you could send me the trace output please? Alternatively you may just use the bttestui app to which the above link points to.

--
Alex



More information about the Interest mailing list