问题
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:
When I select the "XTREME" device and click "PAIR", I get an "Unsupported device" error at the console as shown below:
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!
回答1:
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
来源:https://stackoverflow.com/questions/59653422/bluetooth-connectivity-using-pwa