BluetoothEmulation 接口
🌐 BluetoothEmulation interface
启用蓝牙模拟功能。
🌐 Exposes the bluetooth emulation abilities.
语法
🌐 Signature
export interface BluetoothEmulation
附注
🌐 Remarks
Web Bluetooth 规范 要求模拟适配器应按顶层可导航对象进行隔离。然而,目前 Chromium 的蓝牙模拟实现是绑定到浏览器上下文,而不是页面。这意味着从同一浏览器上下文的不同页面暴露的蓝牙模拟会相互干扰它们的状态。
示例
🌐 Example
await page.bluetooth.emulateAdapter('powered-on');
await page.bluetooth.simulatePreconnectedPeripheral({
address: '09:09:09:09:09:09',
name: 'SOME_NAME',
manufacturerData: [
{
key: 17,
data: 'AP8BAX8=',
},
],
knownServiceUuids: ['12345678-1234-5678-9abc-def123456789'],
});
await page.bluetooth.disableEmulation();
方法
🌐 Methods
方法 🌐 Method | 描述 🌐 Description |
|---|---|
| disableEmulation() | (实验性) 禁用模拟蓝牙适配器。请参阅 bluetooth.disableSimulation。 |
| emulateAdapter(state, leSupported) | (实验性) 模拟蓝牙适配器。蓝牙模拟所必需。请参阅 bluetooth.simulateAdapter。 |
| simulatePreconnectedPeripheral(preconnectedPeripheral) | (实验性) 模拟预连接的蓝牙外设。请参阅 bluetooth.simulatePreconnectedPeripheral。 |