On Sun, May 13, 2018 at 10:11 AM Willem Ferguson <
[email protected]> wrote:

> I am currently without any way of downloading my Petrel 2 to Subsurface.

> On the latest  desktop master, I select Choose Bluetooth. I then force
> download using Classic Bluetooth. No success. I activate the download
> dumpfile and logfile. The logfile is empty, just with the header below.
> There is no dumpfile.

> Subsurface: v4.6.4-2174-g6f3c7386a62a, built with libdivecomputer
> v0.7.0-devel-Subsurface-NG (e97a47cca55973199715df0f818b4955e60d3a31)

According to the log, you're simply not connecting. And you have that

    Connection on channel 1 failed. Trying on channel number 5.

hack, and I really wonder if it's just garbage, and the problem is that
it's not on either of those ports, and we're just making it unnecessarily
complicated - and getting it wrong - by specifying the channel number.

Can you try the attached patch? I don't have any rfcomm devices to test
with.

                    Linus
From ddc1c97821ca96e369ab1549cebe1cc909b08e79 Mon Sep 17 00:00:00 2001
From: Linus Torvalds <[email protected]>
Date: Thu, 26 Apr 2018 10:24:20 -0700
Subject: [PATCH] Clean up rfcomm connection

We don't want to specify the rfcomm channel/port at all, since it can
vary and the system will do the right thing for us anyway if we just
skip it.

Signed-off-by: Linus Torvalds <[email protected]>
---
 core/qtserialbluetooth.cpp | 32 ++------------------------------
 1 file changed, 2 insertions(+), 30 deletions(-)

diff --git a/core/qtserialbluetooth.cpp b/core/qtserialbluetooth.cpp
index bc274dbd9..13f4ee8c5 100644
--- a/core/qtserialbluetooth.cpp
+++ b/core/qtserialbluetooth.cpp
@@ -113,34 +113,6 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t *context, const
 	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}"));
@@ -148,7 +120,7 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t *context, const
 	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);
+	serial_port->socket->connectToService(remoteDeviceAddress, QIODevice::ReadWrite | QIODevice::Unbuffered);
 #endif
 	timer.start(msec);
 	loop.exec();
@@ -160,7 +132,7 @@ static dc_status_t qt_serial_open(qt_serial_t **io, dc_context_t *context, const
 		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
-- 
2.17.0.392.g44117ef7f

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to