diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2018-08-01 13:17:05 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2018-08-16 12:54:08 +0000 |
commit | b2ab732e435ece7b4ae2f3dbfe953ba017403aa8 (patch) | |
tree | 62b02a6a8be9a741febbb4edf85463896f1ead51 /src | |
parent | f602d7fef2e2f067e123e5740d4b0bf16c4ec0e2 (diff) |
Enable new QBluetoothSocket backend for dbus sockets on Bluez 5.46+
The API was introduced earlier than 5.46 already but so far it has not
been tested. For now we use 5.46.
There is another dependency to QLowEnergyController's GATT custom
implementation. Custom GATT only works with the QBluetoothSocket
raw socket implementation. By setting the minimal version for
QBluetoothSocket slightly higher than the 5.42 version for custom
gatt, we ensure that the new dbus socket code is never run together
with the GATT custom stack.
Task-number: QTBUG-68550
Change-Id: I240f7fc8acb116c71e7601df8baf82f61e53c33e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qbluetoothsocket.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 92983de8..9c4ce4d1 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -42,6 +42,7 @@ #if QT_CONFIG(bluez) #include "qbluetoothsocket_bluez_p.h" #include "qbluetoothsocket_bluezdbus_p.h" +#include "bluez/bluez5_helper_p.h" #elif defined(QT_ANDROID_BLUETOOTH) #include "qbluetoothsocket_android_p.h" #elif defined(QT_WINRT_BLUETOOTH) @@ -252,22 +253,32 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT) \reimp */ -/*! - Constructs a Bluetooth socket of \a socketType type, with \a parent. -*/ -QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent) -: QIODevice(parent) +static QBluetoothSocketBasePrivate *createSocketPrivate() { #if QT_CONFIG(bluez) - d_ptr = new QBluetoothSocketPrivateBluez(); - //d_ptr = new QBluetoothSocketPrivateBluezDBus(); + if (bluetoothdVersion() >= QVersionNumber(5, 46)) { + qCDebug(QT_BT) << "Using Bluetooth dbus socket implementation"; + return new QBluetoothSocketPrivateBluezDBus(); + } else { + qCDebug(QT_BT) << "Using Bluetooth raw socket implementation"; + return new QBluetoothSocketPrivateBluez(); + } #elif defined(QT_ANDROID_BLUETOOTH) - d_ptr = new QBluetoothSocketPrivateAndroid(); + return new QBluetoothSocketPrivateAndroid(); #elif defined(QT_WINRT_BLUETOOTH) - d_ptr = new QBluetoothSocketPrivateWinRT(); + return new QBluetoothSocketPrivateWinRT(); #else - d_ptr = new QBluetoothSocketPrivateDummy(); + return new QBluetoothSocketPrivateDummy(); #endif +} + +/*! + Constructs a Bluetooth socket of \a socketType type, with \a parent. +*/ +QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent) +: QIODevice(parent) +{ + d_ptr = createSocketPrivate(); d_ptr->q_ptr = this; Q_D(QBluetoothSocketBase); @@ -282,16 +293,7 @@ QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, Q QBluetoothSocket::QBluetoothSocket(QObject *parent) : QIODevice(parent) { -#if QT_CONFIG(bluez) - d_ptr = new QBluetoothSocketPrivateBluez(); - //d_ptr = new QBluetoothSocketPrivateBluezDBus(); -#elif defined(QT_ANDROID_BLUETOOTH) - d_ptr = new QBluetoothSocketPrivateAndroid(); -#elif defined(QT_WINRT_BLUETOOTH) - d_ptr = new QBluetoothSocketPrivateWinRT(); -#else - d_ptr = new QBluetoothSocketPrivateDummy(); -#endif + d_ptr = createSocketPrivate(); d_ptr->q_ptr = this; setOpenMode(QIODevice::NotOpen); } |