summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-15 03:00:06 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-15 03:00:06 +0100
commitd740076c78252de049beb56b553c8d297af2ac1e (patch)
tree96f64136a9c31532602d707dbf138e9f4dd131b5
parent635ad60e8ead34fc8b0a4bc32ed73618ed041732 (diff)
parentb9502e498c1033b8334afca7808807d3b6f00926 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
-rw-r--r--examples/bluetooth/heartrate-server/heartrate-server.pro1
-rw-r--r--examples/bluetooth/heartrate-server/main.cpp8
-rw-r--r--src/bluetooth/qbluetoothserver_winrt.cpp1
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt_new.cpp53
4 files changed, 48 insertions, 15 deletions
diff --git a/examples/bluetooth/heartrate-server/heartrate-server.pro b/examples/bluetooth/heartrate-server/heartrate-server.pro
index edd011b9..0333ffc9 100644
--- a/examples/bluetooth/heartrate-server/heartrate-server.pro
+++ b/examples/bluetooth/heartrate-server/heartrate-server.pro
@@ -2,6 +2,7 @@ TEMPLATE = app
TARGET = heartrate-server
QT = core bluetooth
+android: QT += gui
CONFIG += c++11
SOURCES += main.cpp
diff --git a/examples/bluetooth/heartrate-server/main.cpp b/examples/bluetooth/heartrate-server/main.cpp
index ea01d07d..7986edd6 100644
--- a/examples/bluetooth/heartrate-server/main.cpp
+++ b/examples/bluetooth/heartrate-server/main.cpp
@@ -57,7 +57,11 @@
#include <QtBluetooth/qlowenergyservice.h>
#include <QtBluetooth/qlowenergyservicedata.h>
#include <QtCore/qbytearray.h>
+#ifndef Q_OS_ANDROID
#include <QtCore/qcoreapplication.h>
+#else
+#include <QtGui/qguiapplication.h>
+#endif
#include <QtCore/qlist.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qscopedpointer.h>
@@ -66,7 +70,11 @@
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+#ifndef Q_OS_ANDROID
QCoreApplication app(argc, argv);
+#else
+ QGuiApplication app(argc, argv);
+#endif
//! [Advertising Data]
QLowEnergyAdvertisingData advertisingData;
diff --git a/src/bluetooth/qbluetoothserver_winrt.cpp b/src/bluetooth/qbluetoothserver_winrt.cpp
index b9d98eb7..884f2285 100644
--- a/src/bluetooth/qbluetoothserver_winrt.cpp
+++ b/src/bluetooth/qbluetoothserver_winrt.cpp
@@ -141,6 +141,7 @@ HRESULT QBluetoothServerPrivate::handleClientConnection(IStreamSocketListener *l
if (pendingConnections.count() < maxPendingConnections) {
qCDebug(QT_BT_WINRT) << "Accepting connection";
pendingConnections.append(socket);
+ locker.unlock();
q->newConnection();
} else {
qCDebug(QT_BT_WINRT) << "Refusing connection";
diff --git a/src/bluetooth/qlowenergycontroller_winrt_new.cpp b/src/bluetooth/qlowenergycontroller_winrt_new.cpp
index a22064fd..f951d1a6 100644
--- a/src/bluetooth/qlowenergycontroller_winrt_new.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt_new.cpp
@@ -833,6 +833,13 @@ void QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails(const QBluetoot
return;
}
+ auto reactOnDiscoveryError = [](QSharedPointer<QLowEnergyServicePrivate> service,
+ const QString &msg)
+ {
+ qCDebug(QT_BT_WINRT) << msg;
+ service->setError(QLowEnergyService::UnknownError);
+ service->setState(QLowEnergyService::DiscoveryRequired);
+ };
//update service data
QSharedPointer<QLowEnergyServicePrivate> pointer = serviceList.value(service);
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
@@ -840,31 +847,43 @@ void QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails(const QBluetoot
pointer->setState(QLowEnergyService::DiscoveringServices);
ComPtr<IGattDeviceService3> deviceService3;
HRESULT hr = deviceService.As(&deviceService3);
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not cast service",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer, QStringLiteral("Could not cast service: %1").arg(hr));
+ return;
+ }
ComPtr<IAsyncOperation<GattDeviceServicesResult *>> op;
hr = deviceService3->GetIncludedServicesAsync(&op);
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain included service list",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer, QStringLiteral("Could not obtain included service list: %1").arg(hr));
+ return;
+ }
ComPtr<IGattDeviceServicesResult> result;
hr = QWinRTFunctions::await(op, result.GetAddressOf());
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not await service operation",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer, QStringLiteral("Could not await service operation: %1").arg(hr));
+ return;
+ }
GattCommunicationStatus status;
hr = result->get_Status(&status);
if (FAILED(hr) || status != GattCommunicationStatus_Success) {
- qCDebug(QT_BT_WINRT) << "Obtaining list of included services failed";
- pointer->setError(QLowEnergyService::UnknownError);
+ reactOnDiscoveryError(pointer,
+ QStringLiteral("Obtaining list of included services failed: %1").arg(hr));
return;
}
ComPtr<IVectorView<GattDeviceService *>> deviceServices;
hr = result->get_Services(&deviceServices);
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain service list from result",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer,
+ QStringLiteral("Could not obtain service list from result: %1").arg(hr));
+ return;
+ }
uint serviceCount;
hr = deviceServices->get_Size(&serviceCount);
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain included service list's size",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer,
+ QStringLiteral("Could not obtain included service list's size: %1").arg(hr));
+ return;
+ }
for (uint i = 0; i < serviceCount; ++i) {
ComPtr<IGattDeviceService> includedService;
hr = deviceServices->GetAt(i, &includedService);
@@ -897,7 +916,7 @@ void QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails(const QBluetoot
connect(worker, &QWinRTLowEnergyServiceHandlerNew::errorOccured,
this, &QLowEnergyControllerPrivateWinRTNew::handleServiceHandlerError);
connect(worker, &QWinRTLowEnergyServiceHandlerNew::charListObtained,
- [this, thread](const QBluetoothUuid &service, QHash<QLowEnergyHandle,
+ [this, reactOnDiscoveryError, thread](const QBluetoothUuid &service, QHash<QLowEnergyHandle,
QLowEnergyServicePrivate::CharData> charList, QVector<QBluetoothUuid> indicateChars,
QLowEnergyHandle startHandle, QLowEnergyHandle endHandle) {
if (!serviceList.contains(service)) {
@@ -917,8 +936,12 @@ void QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails(const QBluetoot
registerForValueChanges(service, indicateChar);
return S_OK;
});
- CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not register for value changes in Xaml thread",
- pointer, QLowEnergyService::UnknownError, return)
+ if (FAILED(hr)) {
+ reactOnDiscoveryError(pointer,
+ QStringLiteral("Could not register for value changes in Xaml thread: %1").arg(hr));
+ thread->exit(0);
+ return;
+ }
pointer->setState(QLowEnergyService::ServiceDiscovered);
thread->exit(0);