diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/bluetooth.pro | 2 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbt.pri | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 14 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_winrt.cpp | 23 |
4 files changed, 31 insertions, 10 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro index a917eefc..84919f98 100644 --- a/src/bluetooth/bluetooth.pro +++ b/src/bluetooth/bluetooth.pro @@ -230,7 +230,7 @@ qtConfig(bluez) { qlowenergycontroller_p.cpp } -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/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 003aff38..d038a8e8 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -346,8 +346,8 @@ void QLowEnergyControllerPrivate::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"; @@ -372,7 +372,6 @@ void QLowEnergyControllerPrivate::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 @@ -406,8 +405,13 @@ void QLowEnergyControllerPrivate::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(); } } @@ -1244,9 +1248,9 @@ void QLowEnergyControllerPrivate::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 3e7c8b20..c9c30b44 100644 --- a/src/bluetooth/qlowenergycontroller_winrt.cpp +++ b/src/bluetooth/qlowenergycontroller_winrt.cpp @@ -404,7 +404,17 @@ void QLowEnergyControllerPrivate::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 QLowEnergyControllerPrivate::obtainIncludedServices(QSharedPointer<QLowEner 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 QLowEnergyControllerPrivate::discoverServiceDetails(const QBluetoothUuid &s 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); |