26 package jau.direct_bt;
28 import java.lang.ref.WeakReference;
29 import java.util.List;
41 final WeakReference<DBTDevice> wbr_device;
43 private final boolean isPrimary;
44 private final String type_uuid;
45 private final short handleStart;
46 private final short handleEnd;
47 final List<BTGattChar> charList;
50 final String type_uuid,
final short handleStart,
final short handleEnd)
52 super(nativeInstance, compHash(handleStart, handleEnd));
53 this.wbr_device =
new WeakReference<DBTDevice>(device);
54 this.isPrimary = isPrimary;
55 this.type_uuid = type_uuid;
56 this.handleStart = handleStart;
57 this.handleEnd = handleEnd;
58 this.charList = getCharsImpl();
62 public boolean equals(
final Object obj)
68 return handleStart == other.handleStart && handleEnd == other.handleEnd;
72 public String
getUUID() {
return type_uuid; }
81 {
throw new UnsupportedOperationException(); }
85 if( !checkServiceCache() ) {
103 public final List<BTGattChar>
getChars() {
return charList; }
124 return "Service" +
"\u271D" +
"[uuid "+
getUUID()+
", handles [0x"+Integer.toHexString(handleStart)+
".."+Integer.toHexString(handleEnd)+
"]]";
126 return toStringImpl();
131 private native String toStringImpl();
133 private native List<BTGattChar> getCharsImpl();
140 boolean checkServiceCache() {
141 final DBTDevice device = wbr_device.get();
142 return null != device && device.checkServiceCache(
false);
173 if( !anyType && !charType && !descType ) {
176 final int characteristicSize = charList.size();
177 for(
int charIdx = 0; charIdx < characteristicSize; charIdx++ ) {
178 final DBTGattChar characteristic = (DBTGattChar) charList.get(charIdx);
179 if( ( anyType || charType ) && (
null == uuid || characteristic.getUUID().equals(uuid) ) ) {
180 return characteristic;
182 if( anyType || descType ) {
183 final DBTObject dbtObj = characteristic.findInCache(uuid, type);
184 if(
null != dbtObj ) {