26 package jau.direct_bt;
28 import java.lang.ref.WeakReference;
29 import java.util.Arrays;
38 final WeakReference<DBTGattChar> wbr_characteristic;
41 private final String type_uuid;
49 private final short handle;
51 private byte[] cachedValue;
53 private void updateCachedValue(
final byte[] value) {
54 if(
null == cachedValue || cachedValue.length != value.length ) {
55 cachedValue =
new byte[value.length];
57 System.arraycopy(value, 0, cachedValue, 0, value.length);
61 final String type_uuid,
final short handle,
final byte[] value)
63 super(nativeInstance, handle );
64 this.wbr_characteristic =
new WeakReference<DBTGattChar>(characteristic);
65 this.type_uuid = type_uuid;
67 this.cachedValue = value;
71 public synchronized void close() {
79 public boolean equals(
final Object obj)
85 return handle == other.handle;
89 public String
getUUID() {
return type_uuid; }
98 {
throw new UnsupportedOperationException(); }
104 public final byte[]
getValue() {
return cachedValue; }
108 final byte[] value = readValueImpl();
109 updateCachedValue(value);
115 final boolean res = writeValueImpl(value);
117 updateCachedValue(value);
133 return "Descriptor" +
"\u271D" +
"[uuid "+
getUUID()+
", handle 0x"+Integer.toHexString(handle)+
"]";
135 return toStringImpl();
140 private native String toStringImpl();
142 private native
byte[] readValueImpl();
144 private native
boolean writeValueImpl(
byte[] argValue)
throws BTException;