gpt4 book ai didi

使用 PWA 的蓝牙连接

转载 作者:行者123 更新时间:2023-12-04 14:16:29 32 4
gpt4 key购买 nike

根据 PWA Web Bluetooth documentation ,它支持“BR/EDR 或 LE 连接”。

我正在尝试在 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); });

我正在使用蓝牙音乐盒进行测试。它被识别为“XTREME”,如下所示:

enter image description here

当我选择“XTREME”设备并单击“PAIR”时,控制台出现“Unsupported device”错误,如下所示:

enter image description here

我尝试了许多其他蓝牙设备并收到相同的“不支持的设备”消息。
到底是怎么回事?不是应该支持吗?我如何知道支持哪种设备?理想情况下,我该怎么做才能知道是否支持我的特定目标设备?

请帮忙!

太棒了!

最佳答案

问题似乎在于 Web 蓝牙只实现了很少的蓝牙协议(protocol)(GATT 和 LE)。

有关蓝牙协议(protocol)的更多信息,请访问:https://en.wikipedia.org/wiki/List_of_Bluetooth_protocols

可以使用 App 来检查设备协议(protocol),看看它是否实现了 GATT 或 LE,以检查 Web 蓝牙兼容性。示例:https://play.google.com/store/apps/details?id=com.sanji.jasper_hsieh.sdpscanner&hl=en

关于使用 PWA 的蓝牙连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59653422/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com