diff options
author | Sven Gothel <[email protected]> | 2020-05-17 09:58:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-05-17 09:58:12 +0200 |
commit | 525cb093d2ead1be30cf860d096129a8ec7146bf (patch) | |
tree | 0bf0e063fc9dfbe7b97cf45301dfe1b859b1e5cf /java/tinyb | |
parent | b12a3e3adf8159a0c252cee67beae35e1b5b879f (diff) |
Working GATT Java Side; GATT Types made fully functional for user to avoid 'technical' GATTHandler
GATT Types made fully functional for user to avoid 'technical' GATTHandler (C++)
> GATTService, GATTCharacteristic, GATTDescriptor
-- Reside in their own respective files
-- Added semantic methods (readValue(), ..) implemented using DBTDevice -> GATTHandler
-- GATTDescriptor owns its value
-- GATTHandler setSendIndicationConfirmation(..) defaults to true
-- Allow user to cirvumvent using GATTHandler manually completely,
device 1--*> services 1--*> characteristics 1--*> descriptor
-- C++ GATT types aligned 1:1 to TinyB (Java)
> Merged GATTIndicationListener + GATTNotificationListener -> GATTCharacteristicListener
-- Simplifying usage, unifying notification and indication
-- Now using a list of shared_ptr<GATTCharacteristicListener> allowing multiple actors
instead of just a one shot entry. Similar to AdapterStatusListener,
we utilize this also on the Java side to implement the TinyB notifications.
See dbt_scanner00.cpp: Simplified high-level usage.
See dbt_scanner01.cpp: Lower-level technical usage w/ GATTHandler.
+++
> Simplified more names
> Removed redundancy in listener callbacks,
-- don't pass adapter when device is already given.
device <*--1> adapter
-- don't pass GATT handle explicitly when characteristic is passed
> Comparison of all GATT types are done by their respective unique handle
Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle)
> GATTHandler: Own L2CAPComm instance directly, instead of shared_ptr.
> JNIMem: Added JNICriticalArray class for RAII style release
++++
++++
Working GATT Java Side
> All toString() methods return the C++ toString() via JNI for better representation.
> DBTDevice.java/JNI: Resolved the odd 'adapter' reference issue:
-- Was not passing the jobject of DBTAdapter, but its shared container refeference ;-)
> All GATT types receive their GATT handler for equal test and identity @ ctor
> GATT read/write Value update the cached value as well as issue the notifyValue on change,
including GATTCharacteristic notification/indication listener
Diffstat (limited to 'java/tinyb')
-rw-r--r-- | java/tinyb/dbus/DBusAdapter.java | 10 | ||||
-rw-r--r-- | java/tinyb/dbus/DBusDevice.java | 17 | ||||
-rw-r--r-- | java/tinyb/dbus/DBusGattCharacteristic.java | 13 |
3 files changed, 38 insertions, 2 deletions
diff --git a/java/tinyb/dbus/DBusAdapter.java b/java/tinyb/dbus/DBusAdapter.java index 2a46f4c7..5b4b26fb 100644 --- a/java/tinyb/dbus/DBusAdapter.java +++ b/java/tinyb/dbus/DBusAdapter.java @@ -149,8 +149,8 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter public native boolean getDiscovering(); @Override - public boolean addStatusListener(final AdapterStatusListener l) { - throw new UnsupportedOperationException(); // FIXME + public boolean addStatusListener(final AdapterStatusListener l, final BluetoothDevice deviceMatch) { + return false; // FIXME } @Override @@ -159,6 +159,11 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter } @Override + public int removeAllStatusListener() { + return 0; // FIXME + } + + @Override public native void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback); @Override @@ -179,6 +184,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter setDiscoveryFilter(uuidsFmt, rssi, pathloss, transportType.ordinal()); } + @SuppressWarnings("unchecked") public void setRssiDiscoveryFilter(final int rssi) { setDiscoveryFilter(Collections.EMPTY_LIST, rssi, 0, TransportType.AUTO); } diff --git a/java/tinyb/dbus/DBusDevice.java b/java/tinyb/dbus/DBusDevice.java index f01bd9e1..fbbebc62 100644 --- a/java/tinyb/dbus/DBusDevice.java +++ b/java/tinyb/dbus/DBusDevice.java @@ -33,10 +33,12 @@ import java.util.Map; import org.tinyb.BluetoothDevice; import org.tinyb.BluetoothException; +import org.tinyb.BluetoothGattCharacteristic; import org.tinyb.BluetoothGattService; import org.tinyb.BluetoothManager; import org.tinyb.BluetoothNotification; import org.tinyb.BluetoothType; +import org.tinyb.GATTCharacteristicListener; public class DBusDevice extends DBusObject implements BluetoothDevice { @@ -202,6 +204,21 @@ public class DBusDevice extends DBusObject implements BluetoothDevice @Override public native void disableServicesResolvedNotifications(); + @Override + public boolean addCharacteristicListener(final GATTCharacteristicListener listener, final BluetoothGattCharacteristic characteristicMatch) { + return false; // FIXME + } + + @Override + public boolean removeCharacteristicListener(final GATTCharacteristicListener l) { + return false; // FIXME + } + + @Override + public int removeAllCharacteristicListener() { + return 0; // FIXME + } + private native void delete(); private DBusDevice(final long instance) diff --git a/java/tinyb/dbus/DBusGattCharacteristic.java b/java/tinyb/dbus/DBusGattCharacteristic.java index 3ca5ab93..6e1e0839 100644 --- a/java/tinyb/dbus/DBusGattCharacteristic.java +++ b/java/tinyb/dbus/DBusGattCharacteristic.java @@ -37,6 +37,7 @@ import org.tinyb.BluetoothGattService; import org.tinyb.BluetoothManager; import org.tinyb.BluetoothNotification; import org.tinyb.BluetoothType; +import org.tinyb.GATTCharacteristicListener; public class DBusGattCharacteristic extends DBusObject implements BluetoothGattCharacteristic { @@ -101,4 +102,16 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC { super(instance); } + @Override + public boolean addCharacteristicListener(final GATTCharacteristicListener listener) { + return false; // FIXME + } + @Override + public boolean removeCharacteristicListener(final GATTCharacteristicListener l) { + return false; // FIXME + } + @Override + public int removeAllCharacteristicListener() { + return 0; // FIXME + } } |