我正在学习 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/