Giter VIP home page Giter VIP logo

Comments (4)

reillyeon avatar reillyeon commented on August 11, 2024

Chrome implements the Bluetooth.requestDevice() method, including its options parameter. The MDN refers to the filters option as an array of BluetoothScanFilter but the spec and Chrome use the name BluetoothLEScanFilterInit, not that this difference is exposed to developers.

While the Permissions API integration is implemented in the sense that the algorithms there describe how permissions are managed the integration with the script-exposed query() method is not. Developers must use Bluetooth.requestDevice() or the upcoming Bluetooth.getDevices() methods to request and query permissions. The getDevices() method is under development and tracked by this ChromeStatus entry.

from web-bluetooth.

hamishwillee avatar hamishwillee commented on August 11, 2024

While the Permissions API integration is implemented in the sense that the algorithms there describe how permissions are managed the integration with the script-exposed query() method is not.

Thanks @reillyeon - much appreciated.

I understand that you are saying that you can't specify options to query and get back permitted devices. It sounds like instead users would check the permitted existing devices using getDevices()?

Just FMI:

  1. Is the intent that you might be able to filter devices using getDevices()?
  2. Is the plan ever to match the spec w.r.t. returning device, or is the intent to get the spec to match Chrome?

Further,

  1. are the spec event handlers all implemented, such as advertisementreceived (these aren't documented on MDN). Do we know the version they appeared in?
  2. What form does optionalManufacturerData actually take? It looks like an array of numbers, but what do those numbers map to? How are they used? It reads as though this is not used for filtering, but is data you want to make available to the origin after filtering.
  3. The spec seems to indicate that options is optional, but not clear what gets fetched in this case. Thoughts?

from web-bluetooth.

reillyeon avatar reillyeon commented on August 11, 2024

I understand that you are saying that you can't specify options to query and get back permitted devices. It sounds like instead users would check the permitted existing devices using getDevices()?

Correct.

  1. Is the intent that you might be able to filter devices using getDevices()?

Filtering devices isn't supported by getDevices(). It's unclear how useful this would be to developers.

  1. Is the plan ever to match the spec w.r.t. returning device, or is the intent to get the spec to match Chrome?

Supporting querying Web Bluetooth device permissions with navigator.permissions.query() would be nice, but when I looked into supporting it for WebUSB there were some technical limitations in the Chromium implementation which meant it was difficult to implement and so I decided it wasn't worth the effort given that the functionality is duplicated by the getDevices() method.

  1. are the spec event handlers all implemented, such as advertisementreceived (these aren't documented on MDN). Do we know the version they appeared in?

The advertisementreceived event handler is used by two related features BluetoothDevice.watchAdvertisements() and navigator.bluetooth.requestLeScan(). Both of these are currently prototyped in Chromium but are not yet enabled by default.

  1. What form does optionalManufacturerData actually take? It looks like an array of numbers, but what do those numbers map to? How are they used? It reads as though this is not used for filtering, but is data you want to make available to the origin after filtering.

It operates similarly to optionalServices. It doesn't filter the devices displayed to the user in the permission prompt but controls which manufacturer data fields provided in advertisementreceived events. Bluetooth manufacturer IDs are integers. The "optional" versions of these parameters are useful because it allows the developer to declare the data they are interested in receiving from the devices without overly constraining the filter controlling which devices are presented to the user in the permission prompt.

  1. The spec seems to indicate that options is optional, but not clear what gets fetched in this case. Thoughts?

You're right that options is not truly optional because one of filters or acceptAllDevices is required.

from web-bluetooth.

hamishwillee avatar hamishwillee commented on August 11, 2024

Thank you very much. I'm going to close this as answered "for now". When the currently experimental bits go live MDN will probably still need quite a bit of work.

FWIW from a developer point of view it is always best if specs match implementation. If matching the spec as it is is not feasible, then working to modify the spec while there are no other implementers would be a "good thing". I'm sure you know that.

from web-bluetooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.