我在我的项目中使用网络蓝牙,我使用此代码连接到设备
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);
}
总是要连接,我调用对话框并在那里选择我需要的设备。我可以以编程方式获取已连接设备的列表吗?为了不每次都调用一个对话框?