ManufacturerDataFilterBuilder constructor
Create a new manufacturer data filter.
companyIdentifier
is a 16 bit identifier of the company that either made
the device, or made the bluetooth chip that the device uses.
See the full list of company identifiers here.
dataPrefix
is a uint8 (or byte) array of the first n bytes of the
manufacturer data of the device. For example if you have the UUID
D273346A-...
then the prefix of D273
should match
mask
is a uint8 (or byte) array of the bits that should be matched against.
The manufacturer data will be bit wise and (&) as well as the dataPrefix
to
the same mask
. These two will then be compared to be equal.
Implementation
ManufacturerDataFilterBuilder(
{final int? companyIdentifier,
final Uint8List? dataPrefix,
final Uint8List? mask})
: _companyIdentifier = companyIdentifier,
_dataPrefix = dataPrefix,
_mask = mask {
if (companyIdentifier != null &&
(companyIdentifier < 0 || companyIdentifier > 0xFFFF)) {
throw ArgumentError(
"The company identifier must fit in 16-bits, so greater than 0 and smaller than 0xFFFF (65535)",
"companyIdentifier");
}
if (_companyIdentifier == null && _dataPrefix == null && _mask == null) {
throw StateError(
"companyIdentifier, dataPrefix, and mask have not been set. Set at least one of them");
}
}