summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2019-09-27 09:40:48 +0200
committerKonstantin Ritt <ritt.ks@gmail.com>2020-02-11 13:38:37 +0000
commit5f6187cb9e17b55cd2a68ac3094ae6a1879b50a2 (patch)
tree8861ff5cc1e2bdccd39f6e2eecb604aa8d1f8564
parent28837908dc5437ff72fe9b57432563caf78da5cf (diff)
downloadqtconnectivity-5f6187cb9e17b55cd2a68ac3094ae6a1879b50a2.tar.gz
Add descriptor even if the read fails during service discovery
leDescriptorRead() serves two pruposes. Firstly, it informs Qt of the value/result of the read operation. During service discovery it is also used to inform Qt that a descriptor was found. This info is used to build up the internal data structure representing the service, its characteristics and its descriptors. If we have a non-readable descriptor the read failed (as expected) and Qt was never informed about the existence of the descriptor. During service discovery the primary purpose is to inform about the existence of a descriptor though. This patch ensures the notification comes through and we accept the fact that the passed value is not known. Fixes: QTBUG-78201 Change-Id: Id73a27c90905cb769f1cd168b48299d580587594 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 7390de230e3c86049824bef756e4af623a547d61) Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
index 6c548f84..5e8bf484 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
@@ -403,8 +403,15 @@ public class QtBluetoothLE {
descriptor.getUuid().toString(), descriptor.getValue());
} else {
if (isServiceDiscoveryRun) {
- //ignore
- Log.w(TAG, "onDescriptorcRead during discovery error: " + status);
+ // Cannot read but still advertise the fact that we found a descriptor
+ // The value will be empty.
+ Log.w(TAG, "onDescriptorRead during discovery error: " + status);
+ Log.d(TAG, "Non-readable descriptor " + descriptor.getUuid() +
+ " for characteristic " + descriptor.getCharacteristic().getUuid() +
+ " for service " + descriptor.getCharacteristic().getService().getUuid());
+ leDescriptorRead(qtObject, descriptor.getCharacteristic().getService().getUuid().toString(),
+ descriptor.getCharacteristic().getUuid().toString(), foundHandle + 1,
+ descriptor.getUuid().toString(), descriptor.getValue());
} else {
// This must be in sync with QLowEnergyService::DescriptorReadError
final int descriptorReadError = 6;