diff options
author | Sven Gothel <[email protected]> | 2022-05-06 19:32:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-06 19:32:11 +0200 |
commit | 662486318a7509f2d610dbbcb39f1073d8b413c1 (patch) | |
tree | df0f9f1ed1e33de14352280ad51ebf3de9d1fac9 /java/org | |
parent | 055a20888b8765b23292145d28f3be9f7a960afd (diff) |
Add BTUtils.toUUID128() and mention it and existing UUID16 definition from DBGatt{Service,Char,Desc} in BTGatt{Service,Char,Desc}
Diffstat (limited to 'java/org')
-rw-r--r-- | java/org/direct_bt/BTGattChar.java | 3 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattDesc.java | 16 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattService.java | 3 | ||||
-rw-r--r-- | java/org/direct_bt/BTUtils.java | 18 | ||||
-rw-r--r-- | java/org/direct_bt/DBGattChar.java | 3 | ||||
-rw-r--r-- | java/org/direct_bt/DBGattDesc.java | 3 | ||||
-rw-r--r-- | java/org/direct_bt/DBGattService.java | 7 |
7 files changed, 38 insertions, 15 deletions
diff --git a/java/org/direct_bt/BTGattChar.java b/java/org/direct_bt/BTGattChar.java index 35493626..62cd8653 100644 --- a/java/org/direct_bt/BTGattChar.java +++ b/java/org/direct_bt/BTGattChar.java @@ -38,6 +38,9 @@ import java.util.List; * * The handle represents a service's characteristics-declaration * and the value the Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID. + * + * See {@link DBGattChar.UUID16} for selected standard GATT characteristic numbers in UUID16 format + * and {@link BTUtils#toUUID128(String)} for their conversion to UUID128. */ public interface BTGattChar extends BTObject { diff --git a/java/org/direct_bt/BTGattDesc.java b/java/org/direct_bt/BTGattDesc.java index fc60e9b9..aaba037b 100644 --- a/java/org/direct_bt/BTGattDesc.java +++ b/java/org/direct_bt/BTGattDesc.java @@ -29,22 +29,12 @@ package org.direct_bt; * Representing a Gatt Characteristic Descriptor object from the GATT client perspective. * * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3 Characteristic Descriptor + * + * See {@link DBGattDesc.UUID16} for selected standard GATT descriptor numbers in UUID16 format + * and {@link BTUtils#toUUID128(String)} for their conversion to UUID128. */ public interface BTGattDesc extends BTObject { - /** - * Following UUID128 values represent original UUID16 GATT profile attribute types, listed under: - * BT Core Spec v5.2: Vol 3, Part G GATT: 3.4 Summary of GATT Profile Attribute Types - */ - public static class UUID128 { - /* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.1 Characteristic Extended Properties */ - public static final String EXT_PROP = "00002900-0000-1000-8000-00805f9b34fb"; - /* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.2 Characteristic User Description (Characteristic Descriptor, optional, single, string) */ - public static final String USER_DESC = "00002901-0000-1000-8000-00805f9b34fb"; - /* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration (Characteristic Descriptor, optional, single, uint16_t bitfield) */ - public static final String CCC_DESC = "00002902-0000-1000-8000-00805f9b34fb"; - } - /** Reads the value of this descriptor * @return A vector<uchar> containing data from this descriptor */ diff --git a/java/org/direct_bt/BTGattService.java b/java/org/direct_bt/BTGattService.java index 43e45cda..62cd04ec 100644 --- a/java/org/direct_bt/BTGattService.java +++ b/java/org/direct_bt/BTGattService.java @@ -36,6 +36,9 @@ import java.util.List; * Includes a complete [Primary] Service Declaration * including its list of Characteristic Declarations, * which also may include its client config if available. + * + * See {@link DBGattService.UUID16} for selected standard GATT service numbers in UUID16 format + * and {@link BTUtils#toUUID128(String)} for their conversion to UUID128. */ public interface BTGattService extends BTObject { diff --git a/java/org/direct_bt/BTUtils.java b/java/org/direct_bt/BTUtils.java index 77515a20..d8a74418 100644 --- a/java/org/direct_bt/BTUtils.java +++ b/java/org/direct_bt/BTUtils.java @@ -29,6 +29,24 @@ import java.io.PrintStream; import org.jau.util.BasicTypes; public class BTUtils { + /** + * Base UUID128 used to express a UUID16, etc. + */ + public static final String UUID128_BASE = "00000000-0000-1000-8000-00805f9b34fb"; + + /** + * Converts the given 4 digits uuid16 value to UUID128 representation. + * @param uuid16 the 4 characters long uuid16 value to convert + * @return UUID128 representation if uuid16 is 4 characters long, otherwise {@link #UUID128_BASE}. + */ + public static final String toUUID128(final String uuid16) { + if( 4 == uuid16.length() ) { + return "0000" + uuid16 + UUID128_BASE.substring(8); + } else { + return UUID128_BASE; + } + } + private static long t0; static { t0 = startupTimeMillisImpl(); diff --git a/java/org/direct_bt/DBGattChar.java b/java/org/direct_bt/DBGattChar.java index 6d93e3f8..0872ba5e 100644 --- a/java/org/direct_bt/DBGattChar.java +++ b/java/org/direct_bt/DBGattChar.java @@ -47,6 +47,9 @@ public final class DBGattChar implements AutoCloseable private final boolean enabledNotifyState = false; private final boolean enabledIndicateState = false; + /** + * Selected standard GATT characteristic numbers in UUID16 format as defined. + */ public static class UUID16 { // // GENERIC_ACCESS diff --git a/java/org/direct_bt/DBGattDesc.java b/java/org/direct_bt/DBGattDesc.java index a780c501..4a7495ab 100644 --- a/java/org/direct_bt/DBGattDesc.java +++ b/java/org/direct_bt/DBGattDesc.java @@ -37,6 +37,9 @@ public final class DBGattDesc implements AutoCloseable private volatile long nativeInstance; /* pp */ long getNativeInstance() { return nativeInstance; } + /** + * Selected standard GATT descriptor numbers in UUID16 format as defined. + */ public static class UUID16 { /* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.1 Characteristic Extended Properties */ public static final String EXT_PROP = "2900"; diff --git a/java/org/direct_bt/DBGattService.java b/java/org/direct_bt/DBGattService.java index 613cea0b..bb8aed32 100644 --- a/java/org/direct_bt/DBGattService.java +++ b/java/org/direct_bt/DBGattService.java @@ -43,6 +43,9 @@ public final class DBGattService implements AutoCloseable private volatile long nativeInstance; /* pp */ long getNativeInstance() { return nativeInstance; } + /** + * Selected standard GATT service service numbers in UUID16 format as defined. + */ public static class UUID16 { /** This service contains generic information about the device. This is a mandatory service. */ public static String GENERIC_ACCESS = "1800"; @@ -55,9 +58,9 @@ public final class DBGattService implements AutoCloseable /** This service exposes temperature and other data from a thermometer intended for healthcare and fitness applications. */ public static String HEALTH_THERMOMETER = "1809"; /** This service exposes manufacturer and/or vendor information about a device. */ - public static String DEVICE_INFORMATION = "180A"; + public static String DEVICE_INFORMATION = "180a"; /** This service exposes the state of a battery within a device. */ - public static String BATTERY_SERVICE = "180F"; + public static String BATTERY_SERVICE = "180f"; }; /** * Indicate whether this service is a primary service. |