summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2018-12-23 09:17:30 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-12-27 15:15:07 -0800
commit09a7736ae1e5a1569a3d9b9f6656baf72136c8e1 (patch)
tree000f2f2e66310648ba965b5bde0f7fa94b78ff11
parenteaed790f2312de41852be3d4b377c7b841a9bee5 (diff)
downloadsubsurface-09a7736ae1e5a1569a3d9b9f6656baf72136c8e1.tar.gz
Core: fix BT on Linux, workaround Qt bug on 5.12.0
After upgrading to Qt 5.12.0, download over BT from a DC did not work any more. On the console the message "Connecting to port is not supported (Uuid required)". Linus noticed earlier that we do rather strange processing in this part of the code related to selecting port 1 or port 5. This all seems not needed (any more), but broader testing is advised. This being stripped from the code, the mentioned error from Qt persisted. That is strange in itself, as we did not reference port numbers any more. Step 2 in this commit is actually using an uuid to the call to connectToService. Choosing an uuid seems relatively straightforward as we can use the same one we already use for Android. That is the default BT RFCOMM Serial Port Profile uuid. Interestingly, when changing to this uuid we run immediately in a Qt runtime error telling us "QDBusPendingReply: type ManagedObjectList is not registered with QtDBus.". For these 2 unexpected Qt messages, QTBUG-72742 was made. Studying the Qt source code at this point reveals a possible workaround. Simply create a local QBluetoothLocalDevice object, which, behind the scenes registers the Qt internal ManagedObjectList with QtDBus. In the meantime, Qt agrees that QTBUG-72742 is valid, and that a fix is to be expected in a future version. At that point in time, the declaration of the QBluetoothLocalDevice can be deleted again. In the end, interfacing over BT works again. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
-rw-r--r--core/qtserialbluetooth.cpp36
1 files changed, 6 insertions, 30 deletions
diff --git a/core/qtserialbluetooth.cpp b/core/qtserialbluetooth.cpp
index cd1fde6f1..272b2cafb 100644
--- a/core/qtserialbluetooth.cpp
+++ b/core/qtserialbluetooth.cpp
@@ -3,6 +3,7 @@
#include <QtBluetooth/QBluetoothAddress>
#include <QtBluetooth/QBluetoothSocket>
+#include <QBluetoothLocalDevice>
#include <QEventLoop>
#include <QTimer>
#include <QDebug>
@@ -114,34 +115,6 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t*, const char* d
timer.setSingleShot(true);
loop.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
-#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
- // First try to connect on RFCOMM channel 1. This is the default channel for most devices
- QBluetoothAddress remoteDeviceAddress(devaddr);
- serial_port->socket->connectToService(remoteDeviceAddress, 1, QIODevice::ReadWrite | QIODevice::Unbuffered);
- timer.start(msec);
- loop.exec();
-
- if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) {
- // It seems that the connection on channel 1 took more than expected. Wait another 15 seconds
- qDebug() << "The connection on RFCOMM channel number 1 took more than expected. Wait another 15 seconds.";
- timer.start(3 * msec);
- loop.exec();
- } else if (serial_port->socket->state() == QBluetoothSocket::UnconnectedState) {
- // Try to connect on channel number 5. Maybe this is a Shearwater Petrel2 device.
- qDebug() << "Connection on channel 1 failed. Trying on channel number 5.";
- serial_port->socket->connectToService(remoteDeviceAddress, 5, QIODevice::ReadWrite | QIODevice::Unbuffered);
- timer.start(msec);
- loop.exec();
-
- if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) {
- // It seems that the connection on channel 5 took more than expected. Wait another 15 seconds
- qDebug() << "The connection on RFCOMM channel number 5 took more than expected. Wait another 15 seconds.";
- timer.start(3 * msec);
- loop.exec();
- }
- }
-#elif defined(Q_OS_ANDROID) || (QT_VERSION >= 0x050500 && defined(Q_OS_MAC))
- // Try to connect to the device using the uuid of the Serial Port Profile service
QBluetoothAddress remoteDeviceAddress(devaddr);
#if defined(Q_OS_ANDROID)
QBluetoothUuid uuid = QBluetoothUuid(QUuid("{00001101-0000-1000-8000-00805f9b34fb}"));
@@ -149,7 +122,10 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t*, const char* d
serial_port->socket->setPreferredSecurityFlags(QBluetooth::NoSecurity);
serial_port->socket->connectToService(remoteDeviceAddress, uuid, QIODevice::ReadWrite | QIODevice::Unbuffered);
#else
- serial_port->socket->connectToService(remoteDeviceAddress, 1, QIODevice::ReadWrite | QIODevice::Unbuffered);
+ QBluetoothLocalDevice dev;
+ QBluetoothUuid uuid = QBluetoothUuid(QUuid("{00001101-0000-1000-8000-00805f9b34fb}"));
+ qDebug() << "Linux Bluez connecting to Uuid" << uuid;
+ serial_port->socket->connectToService(remoteDeviceAddress, uuid, QIODevice::ReadWrite | QIODevice::Unbuffered);
#endif
timer.start(msec);
loop.exec();
@@ -161,7 +137,7 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t*, const char* d
timer.start(4 * msec);
loop.exec();
}
-#endif
+
if (serial_port->socket->state() != QBluetoothSocket::ConnectedState) {
// Get the latest error and try to match it with one from libdivecomputer