Fields Summary |
---|
public static final int | SERVICE_TYPE_PRIMARYPrimary service |
public static final int | SERVICE_TYPE_SECONDARYSecondary service (included by primary services) |
protected BluetoothDevice | mDeviceThe remote device his service is associated with.
This applies to client applications only. |
protected UUID | mUuidThe UUID of this service. |
protected int | mInstanceIdInstance ID for this service. |
protected int | mHandlesHandle counter override (for conformance testing). |
protected int | mServiceTypeService type (Primary/Secondary). |
protected List | mCharacteristicsList of characteristics included in this service. |
protected List | mIncludedServicesList of included services for this service. |
private boolean | mAdvertisePreferredWhether the service uuid should be advertised. |
Methods Summary |
---|
public boolean | addCharacteristic(BluetoothGattCharacteristic characteristic)Add a characteristic to this service.
Requires {@link android.Manifest.permission#BLUETOOTH} permission.
mCharacteristics.add(characteristic);
characteristic.setService(this);
return true;
|
void | addIncludedService(android.bluetooth.BluetoothGattService includedService)Add an included service to the internal map.
mIncludedServices.add(includedService);
|
public boolean | addService(android.bluetooth.BluetoothGattService service)Add an included service to this service.
Requires {@link android.Manifest.permission#BLUETOOTH} permission.
mIncludedServices.add(service);
return true;
|
public BluetoothGattCharacteristic | getCharacteristic(java.util.UUID uuid)Returns a characteristic with a given UUID out of the list of
characteristics offered by this service.
This is a convenience function to allow access to a given characteristic
without enumerating over the list returned by {@link #getCharacteristics}
manually.
If a remote service offers multiple characteristics with the same
UUID, the first instance of a characteristic with the given UUID
is returned.
for(BluetoothGattCharacteristic characteristic : mCharacteristics) {
if (uuid.equals(characteristic.getUuid()))
return characteristic;
}
return null;
|
BluetoothGattCharacteristic | getCharacteristic(java.util.UUID uuid, int instanceId)Get characteristic by UUID and instanceId.
for(BluetoothGattCharacteristic characteristic : mCharacteristics) {
if (uuid.equals(characteristic.getUuid())
&& characteristic.getInstanceId() == instanceId)
return characteristic;
}
return null;
|
public java.util.List | getCharacteristics()Returns a list of characteristics included in this service.
return mCharacteristics;
|
BluetoothDevice | getDevice()Returns the device associated with this service.
return mDevice;
|
int | getHandles()Get the handle count override (conformance testing.
return mHandles;
|
public java.util.List | getIncludedServices()Get the list of included GATT services for this service.
return mIncludedServices;
|
public int | getInstanceId()Returns the instance ID for this service
If a remote device offers multiple services with the same UUID
(ex. multiple battery services for different batteries), the instance
ID is used to distuinguish services.
return mInstanceId;
|
public int | getType()Get the type of this service (primary/secondary)
return mServiceType;
|
public java.util.UUID | getUuid()Returns the UUID of this service
return mUuid;
|
public boolean | isAdvertisePreferred()Returns whether the uuid of the service should be advertised.
return mAdvertisePreferred;
|
public void | setAdvertisePreferred(boolean advertisePreferred)Set whether the service uuid should be advertised.
this.mAdvertisePreferred = advertisePreferred;
|
public void | setHandles(int handles)Force the number of handles to reserve for this service.
This is needed for conformance testing only.
mHandles = handles;
|
public void | setInstanceId(int instanceId)Force the instance ID.
This is needed for conformance testing only.
mInstanceId = instanceId;
|