Package ej.bluetooth

Class BluetoothScanFilter


  • public class BluetoothScanFilter
    extends Object
    The BluetoothScanFilter class represents a scan filter which may be used in order to filter scan results during a scan.

    Scan filters can be created by calling the static methods of this class.

    • Constructor Detail

      • BluetoothScanFilter

        public BluetoothScanFilter()
    • Method Detail

      • noFilter

        public static BluetoothScanFilter noFilter()
        Creates a new scan filter. If this filter is set, no scan result will be discarded.
        Returns:
        the new scan filter.
      • fieldExists

        public static BluetoothScanFilter fieldExists​(byte type)
        Creates a new scan filter. If a scan result is received while this filter is set, the scan result is discarded if its advertisement data does not contain the field with the given type.
        Parameters:
        type - the type of the field which must be present within the advertisement data (see BluetoothDataTypes).
        Returns:
        the new scan filter.
      • fieldEquals

        public static BluetoothScanFilter fieldEquals​(byte type,
                                                      byte[] data)
        Creates a new scan filter. If a scan result is received while this filter is set, the scan result is discarded if its advertisement data does not contain the field with the given type or if its data is not equal to the given data.
        Parameters:
        type - the type of the field which must be present within the advertisement data (see BluetoothDataTypes).
        data - the data that the field must be equal to.
        Returns:
        the new scan filter.
      • fieldStartsWith

        public static BluetoothScanFilter fieldStartsWith​(byte type,
                                                          byte[] data)
        Creates a new scan filter. If a scan result is received while this filter is set, the scan result is discarded if its advertisement data does not contain the field with the given type or if its data does not start with the given data.
        Parameters:
        type - the type of the field which must be present within the advertisement data (see BluetoothDataTypes).
        data - the data that the field must start with.
        Returns:
        the new scan filter.