小编Rum*_*ato的帖子

网络蓝牙,获取配对设备列表

我在我的项目中使用网络蓝牙,我使用此代码连接到设备

async function requestDevice() {
    bluetoothDevice = await navigator.bluetooth.requestDevice({
        // filters: [ { name: 'Device test' } ],
        acceptAllDevices: true,
        optionalServices: [
            'battery_service',
            '03b80e5a-ede8-4b33-a751-6ce34ec4c700'
        ]
    });

    bluetoothDevice.addEventListener('gattserverdisconnected', onDisconnected);       
} 
Run Code Online (Sandbox Code Playgroud)

始终要进行连接,我会调用该对话框,然后在其中选择我需要的设备。我可以通过编程方式获取已连接设备的列表吗?为了不每次都调用对话框?

javascript bluetooth web web-bluetooth

1
推荐指数
1
解决办法
2061
查看次数

标签 统计

bluetooth ×1

javascript ×1

web ×1

web-bluetooth ×1