diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-05-16 15:11:57 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-05-23 13:32:47 +0000 |
commit | ca248e3667f52f951bdd60d923b25a6b8fb4296d (patch) | |
tree | 5b54e427c3e6d0b2d7b18c07ec5867101754ea09 /src/bluetooth/qlowenergycontroller_bluez.cpp | |
parent | 4593b79d84b9c8cc818d3c30e3882d699228339f (diff) |
Make it more obvious that another active BTLE connection prevents connect
Task-number: QTBUG-55150
Change-Id: I223e2b2015e210162e59fb994b9352e790b036d4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 3873664a..40744670 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -527,6 +527,17 @@ void QLowEnergyControllerPrivate::connectToDevice() if (l2cpSocket) delete l2cpSocket; + // check for active running connections + // BlueZ 5.37+ (maybe even earlier versions) can have pending BTLE connections + // Only one active L2CP socket to CID 0x4 possible at a time + QVector<quint16> activeHandles = hciManager->activeLowEnergyConnections(); + if (!activeHandles.isEmpty()) { + qCWarning(QT_BT_BLUEZ) << "Cannot connect due to pending active LE connections"; + setError(QLowEnergyController::ConnectionError); + setState(QLowEnergyController::UnconnectedState); + return; + } + l2cpSocket = new QBluetoothSocket(QBluetoothServiceInfo::L2capProtocol, this); connect(l2cpSocket, SIGNAL(connected()), this, SLOT(l2cpConnected())); connect(l2cpSocket, SIGNAL(disconnected()), this, SLOT(l2cpDisconnected())); |