ScannerFilter

public class ScannerFilter

This class represents a Scanner filter.

A scanner filter allows the developer to filter un-wanted devices that are not compatible with the system using naming and MAC criteria.

Use the Builder class to get a valid configuration.

See also: ScannerConfiguration

Fields

MAC_PATTERN

public static final Pattern MAC_PATTERN

Regex used to validate the MAC address.

Methods

filter

public boolean filter(String name, String address)

Checks if the passed parameters are compliant with this filter.

Several criteria can be configured:

  • Inclusive MAC list - If the passed MAC is in the list, it passes the filter;

  • Exclusive MAC list - If the passed MAC is in the list, it doesn’t pass the filter;

  • Inclusive name list - If the passed name contains an inclusive name and no exclusive name, it passes the filter;

  • Exclusive name list - If the passed name doesn’t contain an exclusive name, it passes the filter.

A device with Constants.KALLISTO_DFU_NAME always passes the filter.

There are some priorities relating the filters since it isn’t obligatory to configure all lists. If there is any MAC in an inclusive MAC list, this list decides the outcome. If this list is empty, next it evaluates the exclusive MAC list. If the MAC passes this list, the name lists are evaluated next.

If no list is configured, all devices pass the filter.

Parameters
  • name – The advertising name. If name length is 0 or null, the device doesn’t pass the filter.

  • address – The MAC address. Should follow the MAC_PATTERN.

Returns

true if the device complies with the filter.