28import java.lang.ref.WeakReference;
30import org.direct_bt.BTException;
31import org.direct_bt.BTGattDesc;
36 final WeakReference<DBTGattChar> wbr_characteristic;
39 private final String type_uuid;
47 private final short handle;
49 private byte[] cachedValue;
51 private void updateCachedValue(
final byte[] value) {
52 if(
null == cachedValue || cachedValue.length != value.length ) {
53 cachedValue =
new byte[value.length];
55 System.arraycopy(value, 0, cachedValue, 0, value.length);
59 final String type_uuid,
final short handle,
final byte[] value)
61 super(nativeInstance, handle );
62 this.wbr_characteristic =
new WeakReference<DBTGattChar>(characteristic);
63 this.type_uuid = type_uuid;
65 this.cachedValue = value;
69 public synchronized void close() {
77 public boolean equals(
final Object obj)
83 return handle == other.handle;
87 public String
getUUID() {
return type_uuid; }
93 public final byte[]
getValue() {
return cachedValue; }
97 final byte[] value = readValueImpl();
98 updateCachedValue(value);
104 final boolean res = writeValueImpl(value);
106 updateCachedValue(value);
122 return "Descriptor" +
"\u271D" +
"[uuid "+
getUUID()+
", handle 0x"+Integer.toHexString(handle)+
"]";
124 return toStringImpl();
129 private native String toStringImpl();
131 private native
byte[] readValueImpl();
133 private native
boolean writeValueImpl(
byte[] argValue)
throws BTException;
boolean equals(final Object obj)
final DBTGattChar getCharacteristic()
Returns the characteristic to which this descriptor belongs to.
synchronized void close()
Release the native memory associated with this object The object should not be used following a call ...
final byte[] readValue()
Reads the value of this descriptor.
final boolean writeValue(final byte[] value)
Writes the value of this descriptor.
final byte[] getValue()
Returns the cached value of this descriptor, if any.
final short getHandle()
Characteristic Descriptor Handle.
String getUUID()
Get the UUID of this descriptor.
native void deleteImpl(long nativeInstance)
Deletes the native instance.
final boolean isNativeValid()
Returns true if native instance is valid, otherwise false.
Representing a Gatt Characteristic Descriptor object from the GATT client perspective.