Skip to content

Commit 06c5205

Browse files
committed
docs: include manufacturerData in scan filters
1 parent 11ee374 commit 06c5205

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,15 @@ Stop listening to the changes of the value of a characteristic. For an example,
935935
| **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
936936
| **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) |
937937
| **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) |
938+
| **`manufacturerData`** | <code>ManufacturerDataFilter[]</code> | Allow scanning for devices with a specific manufacturer data https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata |
939+
940+
#### ManufacturerDataFilter
941+
942+
| Prop | Type | Description |
943+
| ----------------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
944+
| **`companyIdentifier`** | <code>number</code> | Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field. |
945+
| **`dataPrefix`** | <code><a href="#uint8array">Uint8Array</a></code> | Prefix to match in the manufacturer data field. On **Android** this field is mandatory. |
946+
| **`mask`** | <code><a href="#uint8array">Uint8Array</a></code> | Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0. The `mask` must have the same length of dataPrefix. |
938947

939948
#### ScanResult
940949

src/definitions.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface RequestBleDeviceOptions {
5050
* Allow scanning for devices with a specific manufacturer data
5151
* https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata
5252
*/
53-
manufacturerData?: { companyIdentifier: number; dataPrefix?: Uint8Array; mask?: Uint8Array }[];
53+
manufacturerData?: ManufacturerDataFilter[];
5454
}
5555

5656
/**
@@ -95,6 +95,25 @@ export enum ConnectionPriority {
9595
CONNECTION_PRIORITY_LOW_POWER = 2,
9696
}
9797

98+
export interface ManufacturerDataFilter {
99+
/**
100+
* Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field.
101+
*/
102+
companyIdentifier: number;
103+
104+
/**
105+
* Prefix to match in the manufacturer data field.
106+
* On **Android** this field is mandatory.
107+
*/
108+
dataPrefix?: Uint8Array;
109+
110+
/**
111+
* Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.
112+
* The `mask` must have the same length of dataPrefix.
113+
*/
114+
mask?: Uint8Array;
115+
}
116+
98117
export interface BleDevice {
99118
/**
100119
* ID of the device, which will be needed for further calls.
@@ -297,12 +316,12 @@ export interface BluetoothLePlugin {
297316
getBondedDevices(): Promise<GetDevicesResult>;
298317
addListener(
299318
eventName: 'onEnabledChanged',
300-
listenerFunc: (result: BooleanResult) => void,
319+
listenerFunc: (result: BooleanResult) => void
301320
): Promise<PluginListenerHandle>;
302321
addListener(eventName: string, listenerFunc: (event: ReadResult) => void): Promise<PluginListenerHandle>;
303322
addListener(
304323
eventName: 'onScanResult',
305-
listenerFunc: (result: ScanResultInternal) => void,
324+
listenerFunc: (result: ScanResultInternal) => void
306325
): Promise<PluginListenerHandle>;
307326
connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
308327
createBond(options: DeviceIdOptions & TimeoutOptions): Promise<void>;

0 commit comments

Comments
 (0)