28import java.lang.ref.WeakReference;
31import org.direct_bt.BTDevice;
32import org.direct_bt.BTGattChar;
33import org.direct_bt.BTGattService;
38 final WeakReference<DBTDevice> wbr_device;
40 private final boolean isPrimary;
41 private final String type_uuid;
42 private final short handleStart;
43 private final short handleEnd;
44 final List<BTGattChar> charList;
47 final String type_uuid,
final short handleStart,
final short handleEnd)
49 super(nativeInstance, compHash(handleStart, handleEnd));
50 this.wbr_device =
new WeakReference<DBTDevice>(device);
51 this.isPrimary = isPrimary;
52 this.type_uuid = type_uuid;
53 this.handleStart = handleStart;
54 this.handleEnd = handleEnd;
55 this.charList = getCharsImpl();
59 public boolean equals(
final Object obj)
65 return handleStart == other.handleStart && handleEnd == other.handleEnd;
69 public String
getUUID() {
return type_uuid; }
73 {
throw new UnsupportedOperationException(); }
77 final DBTDevice device = wbr_device.get();
78 if(
null == device ) {
81 final int characteristicSize = charList.size();
82 for(
int charIdx = 0; charIdx < characteristicSize; charIdx++ ) {
84 if( characteristic.
getUUID().equals(char_uuid) ) {
85 return characteristic;
98 public final List<BTGattChar>
getChars() {
return charList; }
119 return "Service" +
"\u271D" +
"[uuid "+
getUUID()+
", handles [0x"+Integer.toHexString(handleStart)+
".."+Integer.toHexString(handleEnd)+
"]]";
121 return toStringImpl();
126 private native String toStringImpl();
128 private native List<BTGattChar> getCharsImpl();
String getUUID()
Get the UUID of this characteristic.
String getUUID()
Get the UUID of this service.
BTGattChar findGattChar(final String char_uuid)
Find a BTGattChar by its char_uuid.
final short getHandleEnd()
Returns the service end handle.
final short getHandleStart()
Returns the service start handle.
final List< BTGattChar > getChars()
Returns a list of BTGattChar this service exposes.
final BTDevice getDevice()
Returns the device to which this service belongs to.
final boolean getPrimary()
Returns true if this service is a primary service, false if secondary.
boolean equals(final Object obj)
native void deleteImpl(long nativeInstance)
Deletes the native instance.
final BTGattService clone()
final boolean isNativeValid()
Returns true if native instance is valid, otherwise false.
BTDevice represents one remote Bluetooth device.
Representing a Gatt Characteristic object from the GATT client perspective.
Representing a Gatt Service object from the GATT client perspective.