Craig
Craig

Reputation: 13

Can you access the Chrome Web Bluetooth available pairs list?

Sorry if the question title is a bit confusing.

I am trying to learn more about the (limited) use cases of the Web Bluetooth api for browsers, and I was wondering if there was a simple way to return the list of all detected/scanned bluetooth devices.

As you can see in the image when using one of the samples provided, when we want to pair to a device Chrome shows us a list of all available bluetooth devices, in the list shown there are a list of beacons that I have purchased.

In my use case I just want to display in my own UI the list of the beacons that we see there, not actually pair to any device. I tried requestLEScanhowever that does not seem to be what I am looking for.

Upvotes: 1

Views: 618

Answers (1)

Daniel Bank
Daniel Bank

Reputation: 3899

At the time of this writing, the short answer is no. You cannot display your own chooser UI for listing available devices.

Currently, the Bluetooth interface only provides methods for checking whether the user-agent can support Bluetooth (getAvailability()) and for requesting a device using the Browser-provided chooser UI (requestDevice()). The requestDevice() function call returns a Promise which resolves with the BluetoothDevice that was chosen via that UI. In the case that there is no chooser UI, it just returns the first device matching the criteria.

There is a Draft Web Bluetooth Scanning API which includes the requestLEScan function that you mentioned in your question. This function would allow the user-agent to scan for BLE advertisements. With this API, the use case described in your question could work (showing a list of beacons is the example in the draft). However this is not the same as accessing the Chrome Web Bluetooth available pairs list (which is the question title). It is just for receiving the advertising packets. As you probably know, not all BLE devices send advertising packets.

Edit: Previously I mentioned that "BLE is not the same as Bluetooth (which doesn't have an advertising capability)". This is true. However, a more important statement is that Web Bluetooth only works with BLE devices.

Upvotes: 1

Related Questions