summaryrefslogtreecommitdiffstats
path: root/java/tinyb
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-08-26 16:40:42 +0200
committerSven Gothel <[email protected]>2020-08-26 16:40:42 +0200
commit351e6293c45b3e2a37d5d771bb953aa883d9c1dd (patch)
treebc5a3f8f85e23ce527012646e4fc98be6ab50f1e /java/tinyb
parent1d8d9c8bfac90059d928704316171725c23601f1 (diff)
BluetoothGattCharacteristic: API Change: 'writeValue(byte[] value)' -> 'writeValue(byte[] value, boolean withResponse)'
Add both writeValue(..) mapping to Java [1] BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response [2] BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value Previously only [1] existed and [2] seemingly isn't supported by DBus yet(?) Adding the additional paramter 'boolean withResponse' to determine which variant is desired, while removing the original method type. The TinyB/DBus implementation will throw a BluetoothException if 'withResponse' == true, as it is not supported. This change allows clarification of the actual method being desired and supports a fail fast if not supported.
Diffstat (limited to 'java/tinyb')
-rw-r--r--java/tinyb/dbus/DBusBluetoothException.java38
-rw-r--r--java/tinyb/dbus/DBusGattCharacteristic.java8
2 files changed, 45 insertions, 1 deletions
diff --git a/java/tinyb/dbus/DBusBluetoothException.java b/java/tinyb/dbus/DBusBluetoothException.java
new file mode 100644
index 00000000..5fcfbfe5
--- /dev/null
+++ b/java/tinyb/dbus/DBusBluetoothException.java
@@ -0,0 +1,38 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Petre Eftime <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import org.tinyb.BluetoothException;
+
+@SuppressWarnings("serial")
+public class DBusBluetoothException extends BluetoothException {
+ DBusBluetoothException(final String msg) {
+ super(msg);
+ }
+}
diff --git a/java/tinyb/dbus/DBusGattCharacteristic.java b/java/tinyb/dbus/DBusGattCharacteristic.java
index 2fcbfb39..9d9700e7 100644
--- a/java/tinyb/dbus/DBusGattCharacteristic.java
+++ b/java/tinyb/dbus/DBusGattCharacteristic.java
@@ -72,7 +72,13 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC
public native void disableValueNotifications();
@Override
- public native boolean writeValue(byte[] argValue) throws BluetoothException;
+ public boolean writeValue(final byte[] argValue, final boolean withResponse) throws BluetoothException {
+ if( withResponse ) {
+ throw new DBusBluetoothException("writeValue with response not yet supported");
+ }
+ return writeValueImpl(argValue);
+ }
+ private native boolean writeValueImpl(byte[] argValue) throws BluetoothException;
/* D-Bus property accessors: */