W3C home > Mailing lists > Public > public-web-bluetooth-log@w3.org > May 2016

Re: [web-bluetooth] Have sites explicitly watch for advertisements on paired devices.

From: François Beaufort via GitHub <sysbot+gh@w3.org>
Date: Wed, 04 May 2016 08:00:52 +0000
To: public-web-bluetooth-log@w3.org
Message-ID: <issue_comment.created-216771845-1462348850-sysbot+gh@w3.org>
If we really want these two steps, I'd advise for consistency with 
`startNotifications()/stopNotifications()` and make 
`watchingAdvertisements` a function like 
`startWatchingAdvertisements()/stopWatchingAdvertisements()`:

```js
var known_service = "A service in the iBeacon’s GATT server";
return navigator.bluetooth.requestDevice({
  filters: [{services: [known_service]}]
}).then(device => {
  device.startWatchingAdvertisements();
  device.addEventListener('advertisementreceived', interpretIBeacon);
});

// Later on...
device.stopWatchingAdvertisements();
```

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at 
https://github.com/WebBluetoothCG/web-bluetooth/pull/235#issuecomment-216771845
 using your GitHub account
Received on Wednesday, 4 May 2016 08:02:50 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 4 May 2016 08:02:51 UTC