[Interest] Qt Bluetooth in Linux non-functional?

Alexander Zakharov alexander.v.zakharov at gmail.com
Mon Apr 28 08:29:52 CEST 2014


I have installed Qt 5.3 beta and tried to run my tests as well as 
Bluetooth Scanner example provided in Qt. It made no difference with Qt 
5.2.1, but it seems I have found a clue.

I have noticed that when my program is running (it is a simple console 
application requiring manual termination), service discovery by 
bluez-test-device command also does not work, producing an empty output. 
My program worked in the following way:

- run device discovery using QBluetoothDeviceDiscoveryAgent;
- run service discovery using QBluetoothServiceDiscoveryAgent
   from a slot connected to QBluetoothDeviceDiscoveryAgent::finished()
   signal;
- try to create RFCOMM socket using QBluetoothSocket from a slot
   connected to QBluetoothServiceDiscoveryAgent::finished() signal.

Since I know the address of my device, I have tried to work with it 
directly (by creating QBluetoothAddress), eliminating the first step 
(device discovery). Suddenly, everything started to function properly: 
service discovery produced a list of all services and RFCOMM connection 
was established. I have also found that running device discovery and 
then starting service discovery early (for example, from a slot 
connected to QBluetoothDeviceDiscoveryAgent::deviceDiscovered, when 
first device is found), also works.

So, after my experiments I have an impression that service discovery 
fails only if it is started after a complete device discovery, as if the 
device discovery procedure somehow blocks further access to the device, 
and not only in my own program, but in the whole system (service 
discovery by bluez-test-device also stops to work). Manually deleting 
QBluetoothDeviceDiscoveryAgent object before starting service discovery 
does not help. Moreover, this problem does not arise for all devices. I 
have tried to run service discovery for my Android phone, and it seems 
to work even after complete device discovery procedure.

The trace output of failing service discovery is the following:

qt.bluetooth.bluez: Full discovery on:  "00:07:80:5C:24:B9"
qt.bluetooth.bluez: void 
QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWatcher*) 
created "00:07:80:5C:24:B9"
qt.bluetooth.bluez: void 
QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWatcher*) 
Discover restrictions: ""
qt.bluetooth.bluez: void 
QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingCallWatcher*)
qt.bluetooth.bluez: Parsing xml "00:07:80:5C:24:B9" 1 0



More information about the Interest mailing list