diff options
author | Sven Gothel <[email protected]> | 2020-05-18 12:53:49 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-05-18 12:53:49 +0200 |
commit | d2aba7577f74408ee0a9a35d1a96c6f74dcd55a5 (patch) | |
tree | d5137ce5c03f1d7bf9a30d7468108c74df64481d /java/direct_bt/tinyb | |
parent | 55ab45201dc7035487da5286302494bbf840ea67 (diff) |
Expose UUID strings in TinyB compatible fashion (unified uuid128_t) as an option (default = true)
Via DBTManager.setUnifyUUID128Bit(boolean):
Enables or disables uuid128_t consolidation
for native uuid16_t and uuid32_t values before string conversion.
Default is {@code true}, as this represent compatibility with original TinyB D-Bus behavior.
If desired, this value should be set once before the first call of {@link #getBluetoothManager()}!
Diffstat (limited to 'java/direct_bt/tinyb')
-rw-r--r-- | java/direct_bt/tinyb/DBTManager.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/java/direct_bt/tinyb/DBTManager.java b/java/direct_bt/tinyb/DBTManager.java index 4a5212ba..e1c669b9 100644 --- a/java/direct_bt/tinyb/DBTManager.java +++ b/java/direct_bt/tinyb/DBTManager.java @@ -45,6 +45,7 @@ public class DBTManager implements BluetoothManager private static volatile boolean isJVMShuttingDown = false; private static final List<Runnable> userShutdownHooks = new ArrayList<Runnable>(); + private static boolean unifyUUID128Bit = true; static { AccessController.doPrivileged(new PrivilegedAction<Object>() { @@ -122,6 +123,26 @@ public class DBTManager implements BluetoothManager } } + /** + * Returns whether uuid128_t consolidation is enabled + * for native uuid16_t and uuid32_t values before string conversion. + * @see #setUnifyUUID128Bit(boolean) + */ + public static boolean getUnifyUUID128Bit() { return unifyUUID128Bit; } + + /** + * Enables or disables uuid128_t consolidation + * for native uuid16_t and uuid32_t values before string conversion. + * <p> + * Default is {@code true}, as this represent compatibility with original TinyB D-Bus behavior. + * </p> + * <p> + * If desired, this value should be set once before the first call of {@link #getBluetoothManager()}! + * </p> + * @see #getUnifyUUID128Bit() + */ + public static void setUnifyUUID128Bit(final boolean v) { unifyUUID128Bit=v; } + private long nativeInstance; private static DBTManager inst; private final List<BluetoothAdapter> adapters = new ArrayList<BluetoothAdapter>(); @@ -243,11 +264,11 @@ public class DBTManager implements BluetoothManager private native List<BluetoothAdapter> getAdapterListImpl(); - private native void initImpl() throws BluetoothException; + private native void initImpl(final boolean unifyUUID128Bit) throws BluetoothException; private native void deleteImpl(); private DBTManager() { - initImpl(); + initImpl(unifyUUID128Bit); try { adapters.addAll(getAdapterListImpl()); } catch (final BluetoothException be) { |