summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-24 15:09:33 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2014-12-01 12:33:58 +0100
commit78954716c7dfb5334386ba28d09363468a7fead2 (patch)
tree597cc2443e57ce1201d43923d1e7bbc96b32df21 /src/android
parent63a158b2d53a4f18f118a95796c0386911e1e5fa (diff)
Android: Add characteristic indication support
At this point in time characteristic indication is very much under- documented. We have to make some guesses along the way notifications work. Also, it turns out the code already supported indications but was not very future proof. If the ClientCharacteristicConfiguration is expanded by future Bluetooth specifications the notifications could have been enabled despite the two relevant bits not being set. All that was required was to write {0xFC FF} and the notifications would have been enabled. This was due to assumption that only the byte array {0x00 0xFF} being the disabling data set. Change-Id: I6c54d557f51977418f91baf658b62e1121785029 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java19
1 files changed, 15 insertions, 4 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 12935b6a..ea5d6ce6 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
@@ -887,10 +887,21 @@ public class QtBluetoothLE {
must be written to the peripheral
*/
- boolean enableNotifications = true;
- if (Arrays.equals(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE,
- nextJob.newValue))
- enableNotifications = false;
+
+ /* There is no documentation on indication behavior. The assumption is
+ that when indication or notification are requested we call
+ BluetoothGatt.setCharacteristicNotification. Furthermore it is assumed
+ indications are send via onCharacteristicChanged too and Android itself
+ will do the confirmation required for an indication as per
+ Bluetooth spec Vol 3, Part G, 4.11 . If neither of the two bits are set
+ we disable the signals.
+ */
+ boolean enableNotifications = false;
+ int value = (nextJob.newValue[0] & 0xff);
+ // first or second bit must be set
+ if (((value & 0x1) == 1) || (((value >> 1) & 0x1) == 1)) {
+ enableNotifications = true;
+ }
result = mBluetoothGatt.setCharacteristicNotification(
nextJob.entry.descriptor.getCharacteristic(), enableNotifications);