Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth connectivity using PWA

According to PWA Web Bluetooth documentation, it supports "either a BR/EDR or LE connection".

I am trying to test using the following code at the console of the Chrome devtools:

navigator.bluetooth.requestDevice({
  acceptAllDevices: true,
})
.then(device => {
  // Human-readable name of the device.
  console.log(device.name);
  console.log(device.id);
  // Attempts to connect to remote GATT Server.
  return device.gatt.connect();
})
.then(server => { /* ... */ })
.catch(error => { console.error(error); });

I am using a Bluetooth music box to test it. It is recognized as "XTREME" as follows:

enter image description here

When I select the "XTREME" device and click "PAIR", I get an "Unsupported device" error at the console as shown below:

enter image description here

I've tried many other Bluetooth devices and got the same "Unsupported device" message. What is going on? Isn't it supposed to be supported? How do I know which device is supported? Ideally, what do I do to know if my specific target device will be supported?

Please help!

Tks!

like image 886
Chocksmith Avatar asked Nov 15 '25 15:11

Chocksmith


1 Answers

It seems that the problem is that Web Bluetooth only implement few Bluetooth protocols (GATT and LE).

More about Bluetooth protocols can be found here: https://en.wikipedia.org/wiki/List_of_Bluetooth_protocols

One can use and App to inspect the device protocol and see if it implements GATT or LE to check for Web Bluetooth compatibility. Example: https://play.google.com/store/apps/details?id=com.sanji.jasper_hsieh.sdpscanner&hl=en

like image 142
Chocksmith Avatar answered Nov 18 '25 18:11

Chocksmith