Skip to content

Commit

Permalink
update for acceptAllAdvertisements
Browse files Browse the repository at this point in the history
  • Loading branch information
chengweih001 committed Oct 2, 2023
1 parent 40d7aee commit bf5860a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions requestLEScan-for-granted-devices-explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following code snippet shows how to use the new requestLEScan API to listen

```js
let scan = await navigator.bluetooth.requestLEScan({
acceptAllAdvertisements: true, // This is optional.
listenOnlyGrantedDevices: true
});

Expand All @@ -49,6 +50,8 @@ navigator.bluetooth.addEventListener("advertisementreceived", (event) => {
scan.stop();
```

The field `acceptAllAdvertisements` is optional when `listenOnlyGrantedDevices` is true. Calling the API with only `listenOnlyGrantedDevices` being true effectively acts like accepting all advertisements from granted devices.

If the app wants to filter for certain manufacturer data, it can be done by using the `filters` parameter. In the example below, it listens to advertisements from all granted devices and filters for the advertisements that match a pattern whose company code is `0xE0` and the first byte of the manufacturer data is `0x1`.

```js
Expand Down

0 comments on commit bf5860a

Please sign in to comment.