Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.14.1, 5.15.2
-
None
-
Linux peppy 5.5.4-arch1-1 #1 SMP PREEMPT Sat, 15 Feb 2020 00:36:29 +0000 x86_64 GNU/Linux
python-pyqt5 5.14.1-2
bluez 5.53-1
-
-
7aa19c8a512fdceac12cf4ee6587626e3de61c25 (qt/qtconnectivity/dev) e61994ab9d82470fe15f4476eecf2aef1d570f35 (qt/tqtc-qtconnectivity/tqtc/lts-5.15)
Description
Code is broken since bluez version 5.46. Downgrading to 5.45 fix the issue.
When trying to connect to a known, but unavailable device, the connection timeout never occur. No error signal is emitted and it hang in the connecting state for ever. Likewise, no error occur when the adapter is powered off during the connection, so it seems like a communication problem between Bluez and Qt.
systemctl status bluetooth output the following error for HC05 (with both 5.45 and 5.46):
Feb 21 11:55:29 peppy bluetoothd[531]: Unable to get QBluetoothSocket-3619 SDP record: Host is down
Script output in 5.45-1:
connecting ... qt.bluetooth.bluez: SDP scan failure QProcess::NormalExit 3 qt.bluetooth.bluez: SDP search failed for "98:D3:31:40:31:2C" Service cannot be found
Script output in 5.46-2 (hang)
connecting ...
Sample code:
#!/usr/bin/python3 import sys from PyQt5 import QtWidgets, QtBluetooth, QtCore class Main(QtWidgets.QMainWindow): def __init__(self, parent): super().__init__() unavailable_host = "98:D3:31:40:31:2C" # HC05 bluetooth module addr = QtBluetooth.QBluetoothAddress(unavailable_host) uuid = QtBluetooth.QBluetoothUuid(QtBluetooth.QBluetoothUuid.SerialPort) print("connecting ...") self.socket = QtBluetooth.QBluetoothSocket(QtBluetooth.QBluetoothServiceInfo.RfcommProtocol) self.socket.connectToService(addr, uuid, QtCore.QIODevice.ReadWrite) self.socket.connected.connect(self.connected) self.socket.error.connect(self.error) def error(self, error): # Error signal is never emitted print(self.socket.errorString()) def connected(self): # Connected signal is never emitted print("connected") if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) gui = Main(app) sys.exit(app.exec_())
Attachments
For Gerrit Dashboard: QTBUG-82407 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
334001,4 | Fix error handling in BlueZ connectToServiceHelper | dev | qt/qtconnectivity | Status: MERGED | +2 | 0 |
334392,2 | Fix error handling in BlueZ connectToServiceHelper | tqtc/lts-5.15 | qt/tqtc-qtconnectivity | Status: MERGED | +2 | 0 |