summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2019-09-27 09:40:48 +0200
committerAlex Blasche <alexander.blasche@qt.io>2019-09-27 12:29:43 +0200
commit7390de230e3c86049824bef756e4af623a547d61 (patch)
tree6811a2288460e52e8fe14d7fbd3e2133f3388f9f
parentd3ace86011d4e34eeafa795270ac027afd54f857 (diff)
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>
-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;