summaryrefslogtreecommitdiffstats
path: root/src/bluetooth
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-01-20 22:38:09 +0100
committerLiang Qi <liang.qi@qt.io>2018-01-20 22:38:52 +0100
commit1653ae6e8782fb96999a53736a773e9a31d86b8a (patch)
tree33e114d791c9b9db48ceb79ffeb6c1ac7bab3493 /src/bluetooth
parent4462750a68cb93b5d363b6efdbe1d6a6f0e5811f (diff)
parentb274a83bf4f44d0e2642a8e3bd6bada4ccdbf83c (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf Change-Id: I6e93fc7435a49b601a5c10519ed86d2a15125074
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/bluetooth.pro2
-rw-r--r--src/bluetooth/osx/osxbt.pri2
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.cpp3
-rw-r--r--src/bluetooth/qbluetoothserver.cpp3
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp3
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp3
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp14
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt.cpp23
9 files changed, 45 insertions, 10 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index f675b0d9..ee548208 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -247,7 +247,7 @@ qtConfig(bluez) {
PRIVATE_HEADERS += qlowenergycontroller_p.h
}
-winrt-*-msvc2015 {
+winrt {
MODULE_WINRT_CAPABILITIES_DEVICE += \
bluetooth.genericAttributeProfile \
bluetooth.rfcomm
diff --git a/src/bluetooth/osx/osxbt.pri b/src/bluetooth/osx/osxbt.pri
index 13187e4f..0f293107 100644
--- a/src/bluetooth/osx/osxbt.pri
+++ b/src/bluetooth/osx/osxbt.pri
@@ -1,6 +1,6 @@
SOURCES += osx/uistrings.cpp osx/osxbtnotifier.cpp
PRIVATE_HEADERS += osx/uistrings_p.h
-//QMAKE_CXXFLAGS_WARN_ON += -Wno-nullability-completeness
+#QMAKE_CXXFLAGS_WARN_ON += -Wno-nullability-completeness
CONFIG(osx) {
PRIVATE_HEADERS += osx/osxbtutility_p.h \
diff --git a/src/bluetooth/qbluetoothlocaldevice.cpp b/src/bluetooth/qbluetoothlocaldevice.cpp
index e2378460..40d86ae3 100644
--- a/src/bluetooth/qbluetoothlocaldevice.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice.cpp
@@ -55,6 +55,9 @@ QT_BEGIN_NAMESPACE
QBluetoothLocalDevice provides functions for getting and setting the state of local Bluetooth
devices.
+
+ On iOS, this class cannot be used because the platform does not expose
+ any data or API which may provide information on the local Bluetooth device.
*/
/*!
diff --git a/src/bluetooth/qbluetoothserver.cpp b/src/bluetooth/qbluetoothserver.cpp
index 99d3b53a..90c3ff19 100644
--- a/src/bluetooth/qbluetoothserver.cpp
+++ b/src/bluetooth/qbluetoothserver.cpp
@@ -66,6 +66,9 @@ QT_BEGIN_NAMESPACE
If the \l QBluetoothServiceInfo::Protocol is not supported by a platform, \l listen() will return \c false.
Android and WinRT only support RFCOMM for example.
+ On iOS, this class cannot be used because the platform does not expose
+ an API which may permit access to QBluetoothServer related features.
+
\sa QBluetoothServiceInfo, QBluetoothSocket
*/
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index d6163f0e..05d62ab1 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -85,6 +85,9 @@ QT_BEGIN_NAMESPACE
Energy services, it is likely to not advertise them via SDP. The \l QLowEnergyController class
should be utilized to perform the service discovery on Low Energy devices.
+ On iOS, this class cannot be used because the platform does not expose
+ an API which may permit access to QBluetoothServiceDiscoveryAgent related features.
+
\sa QBluetoothDeviceDiscoveryAgent, QLowEnergyController
*/
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index 385e9463..d706e4a7 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -105,6 +105,8 @@ QT_BEGIN_NAMESPACE
service info object share the same data as they do not detach upon changing them. This
ensures that two copies can (de)register the same Bluetooth service.
+ On iOS, this class cannot be used because the platform does not expose
+ an API which may permit access to QBluetoothServiceInfo related features.
*/
/*!
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 6c14cffc..18567f34 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -81,6 +81,9 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT)
\note QBluetoothSocket does not support synchronous read and write operations. Functions such
as \l waitForReadyRead() and \l waitForBytesWritten() are not implemented. I/O operations should be
performed using \l readyRead(), \l read() and \l write().
+
+ On iOS, this class cannot be used because the platform does not expose
+ an API which may permit access to QBluetoothSocket related features.
*/
/*!
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index 72f4c678..c4ff0e7f 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -343,8 +343,8 @@ void QLowEnergyControllerPrivateBluez::handleGattRequestTimeout()
}
if (!openRequests.isEmpty() && requestPending) {
- requestPending = false; // reset pending flag
const Request currentRequest = openRequests.dequeue();
+ requestPending = false; // reset pending flag
qCWarning(QT_BT_BLUEZ).nospace() << "****** Request type 0x" << hex << currentRequest.command
<< " to server/peripheral timed out";
@@ -369,7 +369,6 @@ void QLowEnergyControllerPrivateBluez::handleGattRequestTimeout()
case ATT_OP_EXCHANGE_MTU_REQUEST: // MTU change request
// never received reply to MTU request
// it is safe to skip and go to next request
- sendNextPendingRequest();
break;
case ATT_OP_READ_BY_GROUP_REQUEST: // primary or secondary service discovery
case ATT_OP_READ_BY_TYPE_REQUEST: // characteristic or included service discovery
@@ -403,8 +402,13 @@ void QLowEnergyControllerPrivateBluez::handleGattRequestTimeout()
break;
default:
// not a command used by central role implementation
- return;
+ qCWarning(QT_BT_BLUEZ) << "Missing response for ATT peripheral command: "
+ << hex << command;
+ break;
}
+
+ // spin openRequest queue further
+ sendNextPendingRequest();
}
}
@@ -1241,9 +1245,9 @@ void QLowEnergyControllerPrivateBluez::processReply(
} else if (!isServiceDiscoveryRun) {
// not encryption problem -> abort readCharacteristic()/readDescriptor() run
if (!descriptorHandle)
- emit service->error(QLowEnergyService::CharacteristicReadError);
+ service->setError(QLowEnergyService::CharacteristicReadError);
else
- emit service->error(QLowEnergyService::DescriptorReadError);
+ service->setError(QLowEnergyService::DescriptorReadError);
}
} else {
if (!descriptorHandle)
diff --git a/src/bluetooth/qlowenergycontroller_winrt.cpp b/src/bluetooth/qlowenergycontroller_winrt.cpp
index 99a5af6d..628f1195 100644
--- a/src/bluetooth/qlowenergycontroller_winrt.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt.cpp
@@ -404,7 +404,17 @@ void QLowEnergyControllerPrivateWinRT::connectToDevice()
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IGattReadResult> result;
hr = QWinRTFunctions::await(op, result.GetAddressOf());
- Q_ASSERT_SUCCEEDED(hr);
+ if (hr == E_INVALIDARG) {
+ // E_INVALIDARG happens when user tries to connect to a device that was paired
+ // before but is not available.
+ qCDebug(QT_BT_WINRT) << "Could not obtain characteristic read result that triggers"
+ "device connection. Is the device reachable?";
+ setError(QLowEnergyController::ConnectionError);
+ setState(QLowEnergyController::UnconnectedState);
+ return;
+ } else {
+ Q_ASSERT_SUCCEEDED(hr);
+ }
ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
hr = result->get_Value(&buffer);
Q_ASSERT_SUCCEEDED(hr);
@@ -497,7 +507,9 @@ void QLowEnergyControllerPrivateWinRT::obtainIncludedServices(QSharedPointer<QLo
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IVectorView<GattDeviceService *>> includedServices;
hr = service2->GetAllIncludedServices(&includedServices);
- Q_ASSERT_SUCCEEDED(hr);
+ // Some devices return ERROR_ACCESS_DISABLED_BY_POLICY
+ if (FAILED(hr))
+ return;
uint count;
hr = includedServices->get_Size(&count);
@@ -596,7 +608,12 @@ void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(const QBluetoothUu
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IVectorView<GattDeviceService *>> deviceServices;
hr = deviceService2->GetAllIncludedServices(&deviceServices);
- Q_ASSERT_SUCCEEDED(hr);
+ if (FAILED(hr)) { // ERROR_ACCESS_DISABLED_BY_POLICY
+ qCDebug(QT_BT_WINRT) << "Could not obtain included services list for" << service;
+ pointer->setError(QLowEnergyService::UnknownError);
+ pointer->setState(QLowEnergyService::InvalidService);
+ return;
+ }
uint serviceCount;
hr = deviceServices->get_Size(&serviceCount);
Q_ASSERT_SUCCEEDED(hr);