网络蓝牙:想要在使用 navigator.bluetooth.requestDevice

问题描述

我发现 Google Chrome 没有对制造商数据实施过滤。问题 707635,似乎没有任何进展。

当使用 navigator.bluetooth.requestDevice (https://webbluetoothcg.github.io/web-bluetooth/#example-filter-by-manufacturer-service-data

有谁知道这方面是否有任何进展或进行了这种过滤工作?

解决方法

正如您所指出的,Chrome 团队尚未在这方面取得进展。同时,按设备名称、设备名称前缀或 GATT 服务进行过滤是否适合您?

你可以用 https://googlechrome.github.io/samples/web-bluetooth/device-info.html 试试。

,

简答:

  1. 'Star' 问题 707635 以接收更新和表示感兴趣。
  2. 如果您有一个清晰的示例/业务案例可以分享,请考虑添加评论以帮助开发人员了解如何确定这项工作的优先级。
  3. Chromium 是开源的,请考虑贡献或寻找开发者来完成这项工作。
,

根据我们的讨论,我在 Chrome 92 的网络蓝牙中添加了对制造商数据过滤器的支持。请参阅 https://crbug.com/707635

这是一个例子:

// Filter Bluetooth devices from Google company with manufacturer data bytes
// that start with [0x01,0x02].
navigator.bluetooth.requestDevice({
  filters: [{
    manufacturerData: [{
      companyIdentifier: 0x00e0,dataPrefix: new Uint8Array([0x01,0x02])
    }]
  }],optionalServices: ['battery_service'] // Required to access service later.
})
.then(device => { /* … */ })
.catch(error => { console.error(error); });

您可以在 https://googlechrome.github.io/samples/web-bluetooth/manufacturer-data-filter.html 找到示例,在 https://web.dev/bluetooth/#manufacturer-data-filter

找到一些开发人员文档

让我知道这是否适合你;)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...