diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-02 14:41:38 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-04 09:35:09 +0100 |
commit | 01ea948742b649ad482c2e3e6d914fc1ac5f4917 (patch) | |
tree | fd086faa30826117ab430764efda54984d53d607 /src/android | |
parent | 6d399ac04e1a1cb67444ff6557f425392031d37a (diff) |
Android: enable writing of characteristics without response mode
Change-Id: I9c26aaa11857db8dc33a99d42347a9b7f6281ad7
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.java | 19 |
1 files changed, 18 insertions, 1 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 edeacb82..748d709e 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 @@ -450,6 +450,7 @@ public class QtBluetoothLE { { public GattEntry entry; public byte[] newValue; + public int requestedWriteType; } private final Hashtable<UUID, List<Integer>> uuidToEntry = new Hashtable<UUID, List<Integer>>(100); @@ -805,7 +806,8 @@ public class QtBluetoothLE { /* Write Characteristics */ /*************************************************************/ - public boolean writeCharacteristic(int charHandle, byte[] newValue) + public boolean writeCharacteristic(int charHandle, byte[] newValue, + int writeMode) { if (mBluetoothGatt == null) return false; @@ -822,6 +824,17 @@ public class QtBluetoothLE { newJob.newValue = newValue; newJob.entry = entry; + // writeMode must be in sync with QLowEnergyService::WriteMode + // For now we ignore SignedWriteType as Qt doesn't support it yet. + switch (writeMode) { + case 1: //WriteWithoutResponse + newJob.requestedWriteType = BluetoothGattCharacteristic. WRITE_TYPE_NO_RESPONSE; + break; + default: + newJob.requestedWriteType = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT; + break; + } + boolean result; synchronized (writeQueue) { result = writeQueue.add(newJob); @@ -856,6 +869,7 @@ public class QtBluetoothLE { WriteJob newJob = new WriteJob(); newJob.newValue = newValue; newJob.entry = entry; + newJob.requestedWriteType = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT; boolean result; synchronized (writeQueue) { @@ -891,6 +905,9 @@ public class QtBluetoothLE { boolean result; switch (nextJob.entry.type) { case Characteristic: + if (nextJob.entry.characteristic.getWriteType() != nextJob.requestedWriteType) { + nextJob.entry.characteristic.setWriteType(nextJob.requestedWriteType); + } result = nextJob.entry.characteristic.setValue(nextJob.newValue); if (!result || !mBluetoothGatt.writeCharacteristic(nextJob.entry.characteristic)) skip = true; |