Package ej.bluetooth.util
Class ServiceHelper
- java.lang.Object
-
- ej.bluetooth.util.ServiceHelper
-
public class ServiceHelper extends java.lang.ObjectProvides utility methods related to GATT services.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ej.bluetooth.BluetoothCharacteristicgetCharacteristic(ej.bluetooth.BluetoothService service, ej.bluetooth.BluetoothUuid characteristicUuid)Returns the characteristic with the given UUID in the given service.static ej.bluetooth.BluetoothDescriptorgetDescriptor(ej.bluetooth.BluetoothCharacteristic characteristic, ej.bluetooth.BluetoothUuid descriptorUuid)Returns the descriptor with the given UUID in the given characteristic.static intgetReadPermission(int securityLevel)Returns the read permission for the given security level.static intgetWritePermission(int securityLevel)Returns the write permission for the given security level.static voidprintService(ej.bluetooth.BluetoothService service, java.io.PrintStream printStream)Prints information on the given service to the given print stream.
-
-
-
Method Detail
-
getReadPermission
public static int getReadPermission(int securityLevel)
Returns the read permission for the given security level.- Parameters:
securityLevel- the security level (seeSecurityLevels).- Returns:
- the read permission for the given security level (see
BluetoothPermissions).
-
getWritePermission
public static int getWritePermission(int securityLevel)
Returns the write permission for the given security level.- Parameters:
securityLevel- the security level (seeSecurityLevels).- Returns:
- the write permission for the given security level (see
BluetoothPermissions).
-
getCharacteristic
public static ej.bluetooth.BluetoothCharacteristic getCharacteristic(ej.bluetooth.BluetoothService service, ej.bluetooth.BluetoothUuid characteristicUuid) throws AttributeNotFoundExceptionReturns the characteristic with the given UUID in the given service.If multiple characteristics have the same UUID, any of them may be returned.
- Parameters:
service- the service to search in.characteristicUuid- the UUID of the characteristic to look for.- Returns:
- the characteristic with the given UUID.
- Throws:
AttributeNotFoundException- if this service does not provide a characteristic with the given UUID.
-
getDescriptor
public static ej.bluetooth.BluetoothDescriptor getDescriptor(ej.bluetooth.BluetoothCharacteristic characteristic, ej.bluetooth.BluetoothUuid descriptorUuid) throws AttributeNotFoundExceptionReturns the descriptor with the given UUID in the given characteristic.If multiple descriptors have the same UUID, any of them may be returned.
- Parameters:
characteristic- the characteristic to search in.descriptorUuid- the UUID of the descriptor to look for.- Returns:
- the descriptor with the given UUID.
- Throws:
AttributeNotFoundException- if this characteristic does not provide a descriptor with the given UUID.
-
printService
public static void printService(ej.bluetooth.BluetoothService service, java.io.PrintStream printStream)Prints information on the given service to the given print stream.- Parameters:
service- the service to inspect.printStream- the print stream to print to.
-
-