Package ej.bluetooth

Class BluetoothServiceDefinition


  • public class BluetoothServiceDefinition
    extends Object
    The BluetoothServiceDefinition class represents the structure of a GATT service.

    Service definitions may be created by using the class constructor.

    This class provides methods to add characteristics and descriptors to the service definition.

    • Constructor Detail

      • BluetoothServiceDefinition

        public BluetoothServiceDefinition​(BluetoothUuid serviceUuid)
        Creates a service definition.
        Parameters:
        serviceUuid - the UUID of the service.
    • Method Detail

      • addCharacteristic

        public void addCharacteristic​(BluetoothUuid uuid,
                                      int properties,
                                      int permissions)
        Adds a characteristic to this service definition.
        Parameters:
        uuid - the UUID of the characteristic.
        properties - the properties of the characteristic (see BluetoothProperties.
        permissions - the permissions of the characteristic (see BluetoothPermissions.
      • addDescriptor

        public void addDescriptor​(BluetoothUuid uuid,
                                  int permissions)
        Adds a descriptor to this service definition. The descriptor is attached to the last characteristic added.
        Parameters:
        uuid - the UUID of the descriptor.
        permissions - the permissions of the descriptor (see BluetoothPermissions.
        Throws:
        IllegalStateException - if no characteristic has been added before calling this method.