【问题标题】:Web Bluetooth bypass Pairing Screen for a known device id已知设备 ID 的 Web 蓝牙绕过配对屏幕
【发布时间】:2020-06-23 07:54:35
【问题描述】:

是否可以在没有配对屏幕的情况下连接我知道 ID 的蓝牙设备?

classic:
navigator.bluetooth.requestDevice ({filters: [{services: ['heart_rate']}]})
     .then (device => {
       this.device = device;
       return device.gatt.connect ();

相反,我想在没有 navigator.bluetooth.requestDevice 的情况下执行 device.gatt.connect () .. 至少对于我已经连接过一次或我知道 ID 的设备。

有人可以帮助我吗? ..谢谢!

【问题讨论】:

    标签: javascript web-bluetooth


    【解决方案1】:

    Bluetooth Permissions API integration section of the Web Bluetooth spec 确实指定了一种使用设备 ID 执行此操作的方法。但是,它目前没有在任何浏览器中实现。

    Chrome 中正在进行的工作是实现 getDevices() 方法,该方法可以返回以前授予的蓝牙设备列表。该 API 的状态可以在Chrome Platform Status 中查看。

    6/22/20 编辑:

    我最近实现了一个新的权限后端以及两个 API,这将使以前允许的蓝牙设备能够使用。

    新的权限后端在 chrome://flags/#enable-web-bluetooth-new-permissions-backend 后面实现。新后端将保留通过requestDevice() 授予的设备权限,直到在“站点设置”或“页面信息”对话框中重置该权限。

    getDevices()watchAdvertisements() 在 Chrome 85.0.4165.0 或更高版本的 chrome://flags/#enable-experimental-web-platform-features 标志后面实现。这些 API 的推荐用法是使用 getDevices() 检索允许的 BluetoothDevices 数组,然后在这些设备上调用 watchAdvertisements() 以开始扫描。当从设备检测到广告数据包时,将在其对应的设备上触发advertisementreceived 事件。此时,蓝牙设备在范围内,可以连接。

    请试试这个新功能,并使用 Blink>Bluetooth 组件在https://crbug.com 提交任何错误。

    【讨论】:

    • 谢谢! ..我看到有关于getDecives()的消息..你知道我在哪里可以找到一个例子吗?
    • 目前还没有一个例子,但是这个pull request会在合并后添加一个。
    • 关于此的任何消息,
    猜你喜欢
    • 2015-01-18
    • 1970-01-01
    • 2016-09-26
    • 2020-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多