Class DeviceFilter
Narrows what the system device chooser offers the user.
A request with no filter shows everything the radios can see, which is a
long and confusing list; a request with one good filter usually shows
exactly the accessory the user is holding. Filters within one
AssociationRequest are OR-combined -- a device matching any of them is
offered.
AssociationRequest req = new AssociationRequest.Builder()
.addFilter(DeviceFilter.bleService("180D")) // heart rate
.addFilter(DeviceFilter.namePattern("Acme.*"))
.build();
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFilter kind: match one exact device address.static final intFilter kind: match a BLE service UUID being advertised.static final intFilter kind: match the advertised device name against a regular expression.static final intFilter kind: match a Wi-Fi SSID. -
Method Summary
Modifier and TypeMethodDescriptionstatic DeviceFilterOffers only the device at one exact address -- the reconnect case, where the app already knows which device it wants.static DeviceFilterbleService(String serviceUuid) Offers only devices advertising the given BLE service.intgetKind()Which of theKIND_constants this filter is.getValue()The UUID, pattern, address or SSID, depending ongetKind().static DeviceFilternamePattern(String pattern) Offers only devices whose advertised name matches a regular expression.toString()Returns a string representation of the object.static DeviceFilterOffers only the Wi-Fi network with the given SSID.
-
Field Details
-
KIND_BLE_SERVICE
public static final int KIND_BLE_SERVICEFilter kind: match a BLE service UUID being advertised.- See Also:
-
KIND_NAME_PATTERN
public static final int KIND_NAME_PATTERNFilter kind: match the advertised device name against a regular expression.- See Also:
-
KIND_ADDRESS
public static final int KIND_ADDRESSFilter kind: match one exact device address.- See Also:
-
KIND_WIFI_SSID
public static final int KIND_WIFI_SSIDFilter kind: match a Wi-Fi SSID.- See Also:
-
-
Method Details
-
bleService
Offers only devices advertising the given BLE service.
Parameters
serviceUuid: the service UUID, in either the 16-bit short form ("180D") or the full 128-bit form
Returns
the filter
-
namePattern
Offers only devices whose advertised name matches a regular expression.
The pattern is passed through to the platform, which on Android is
java.util.regexand on iOS is a substring match on the accessory name -- so keep patterns simple if the app runs on both.Parameters
pattern: the pattern to match the name against
Returns
the filter
-
address
Offers only the device at one exact address -- the reconnect case, where the app already knows which device it wants.
Parameters
address: the device address, ascom.codename1.bluetooth.BluetoothDevice#getAddress()reports it
Returns
the filter
-
wifiSsid
Offers only the Wi-Fi network with the given SSID. Android only; ignored on platforms that associate Bluetooth accessories alone.
Parameters
ssid: the network name
Returns
the filter
-
getKind
public int getKind()Which of theKIND_constants this filter is. -
getValue
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-