On Thu, Apr 26, 2018 at 7:44 AM, Jef Driesen <[email protected]> wrote:
>
> I also don't know the exact details on how these port numbers are assigned.
> I guess it depends on the dive computer firmware and/or its bluetooth stack.
> The valid range for rfcomm ports is 1-30 if I remember correctly.
>
> The Petrel is certainly not the only one which is using a different port
> number. I'm currently testing the divecomputer.eu and it seems to use port
> 6.
Ok, sounds like we should use port 0 too.
And that really makes most of the special cases just go away. So a
patch like the attached.
Dirk? Anybody with an rfcomm device? Willing to test the attached
"remove all the crazy crud" patch?
Linus
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
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface