Class ScanFilter

java.lang.Object
com.codename1.bluetooth.le.ScanFilter

public class ScanFilter extends Object

A single scan filter -- all criteria set on one filter are AND-combined; multiple filters added to a ScanSettings are OR-combined. Fluent setters return this for chaining:

new ScanFilter()
    .setServiceUuid(BluetoothUuid.fromShort(0x180D))
    .setNamePrefix("Polar");
  • Constructor Details

    • ScanFilter

      public ScanFilter()
  • Method Details

    • setServiceUuid

      public ScanFilter setServiceUuid(BluetoothUuid uuid)
      Matches devices advertising the given service UUID.
    • setName

      public ScanFilter setName(String exactName)
      Matches devices advertising exactly this local name.
    • setNamePrefix

      public ScanFilter setNamePrefix(String prefix)
      Matches devices whose advertised local name starts with the given prefix.
    • setAddress

      public ScanFilter setAddress(String address)
      Matches the device with the given address (see BluetoothDevice.getAddress() for the per-platform address semantics).
    • setManufacturerData

      public ScanFilter setManufacturerData(int companyId, byte[] data, byte[] mask)
      Matches devices whose advertisement carries manufacturer data for companyId whose leading bytes equal data under mask (a null mask compares all of data exactly). Pass null data to match any payload for the company.
    • getServiceUuid

      public BluetoothUuid getServiceUuid()
      The service UUID criterion, or null when unset. Ports use the getters to push filters down to the platform scanner -- required for background scanning on iOS.
    • getName

      public String getName()
      The exact-name criterion, or null when unset.
    • getNamePrefix

      public String getNamePrefix()
      The name-prefix criterion, or null when unset.
    • getAddress

      public String getAddress()
      The address criterion, or null when unset.
    • getManufacturerId

      public int getManufacturerId()
      The manufacturer-data company identifier criterion, or -1 when unset.
    • getManufacturerData

      public byte[] getManufacturerData()
      The manufacturer-data payload criterion, or null.
    • getManufacturerDataMask

      public byte[] getManufacturerDataMask()
      The manufacturer-data mask, or null (exact comparison).
    • matches

      public boolean matches(ScanResult result)
      true when the given scan result satisfies every criterion of this filter. Used by the core scan demultiplexer; ports may also use it to pre-filter.