javascript - 使用 Web Bluetooth API 时找不到移动设备

标签 javascript android bluetooth

我正在学习 Web Bluetooth API,使用 google dev console,我无法找到我的移动设备。还尝试了 github 上可用的演示
https://github.com/WebBluetoothCG/demos

我正在使用 chrome (dev),启用 webbluetooth 标志 chrome://flags,Ubuntu 16+,Android BLE 4.1 (Marshmallow)

navigator.bluetooth.requestDevice({
        filters: [{
            services: ['battery_service']
        }]
    }).then(device => {
        console.log('Got device:', device.name);
        console.log('id:', device.id);
    });

也尝试将过滤器更改为 {name: 'Device Name'} 后,仍然无法找到我的移动设备。任何建议将不胜感激。

PS:也试过BLE peripheral Simulator

最佳答案

您是否也尝试过 https://googlechrome.github.io/samples/web-bluetooth/battery-level.html使用 BLE 外设模拟器?它应该在支持的平台上工作。参见 https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md#chrome

您提到了 Ubuntu 16+。正如您在 Linux 需求说明 (https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md#notes) 中所见

Linux: Requires Kernel 3.19+ and BlueZ 5.41+ installed. Read How to get Chrome Web Bluetooth working on Linux. Note that Bluetooth daemon needs to run with experimental interfaces: sudo /usr/sbin/bluetoothd -E

关于javascript - 使用 Web Bluetooth API 时找不到移动设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40441258/

相关文章:

Android 依赖层次结构

android - 升级生产 Android 应用程序的 SQLite 数据库,这是正确的吗?

javascript - IONIC BLE(低功耗蓝牙)- 设备列表未显示

ios - CoreBluetooth 状态保存问题 : willRestoreState not called in iOS 7. 1

javascript - 无法理解传递函数来更新状态 Hook 是如何工作的

javascript - 开 Jest - expect(...).toContainEqual 不是一个函数

javascript - Jquery .show 不更改显示属性

android - 如何在我第一次摩擦时只获得一次登录 Activity ,下次应该有不同的 Activity

iphone - iPhone SDK 3.0 中的 GameKit

javascript - 将 bool 值转换为其字符串表示形式的最短方法(例如 'true' )