跳到主要内容

BluetoothEmulation🧪

该域允许配置虚拟蓝牙设备以测试''web-bluetooth API''。

EN
This domain allows configuring virtual Bluetooth devices to test the web-bluetooth API.

✅️️ Methods

🔨BluetoothEmulation.addCharacteristic

向由|serviceId|表示的服务添加一个具有|characteristicUuid|和|properties|特性的特征。

EN
Adds a characteristic with |characteristicUuid| and |properties| to the service represented by |serviceId|.
参数必填标记类型描述原文
serviceId✔️string
characteristicUuid✔️string
properties✔️CharacteristicProperties
返回对象类型描述原文
characteristicIdstring一个唯一标识此特征的标识符。
ENAn identifier that uniquely represents this characteristic.

🔨BluetoothEmulation.addDescriptor

向由 |characteristicId| 表示的特性添加一个具有 |descriptorUuid| 的描述符。

EN
Adds a descriptor with |descriptorUuid| to the characteristic respresented by |characteristicId|.
参数必填标记类型描述原文
characteristicId✔️string
descriptorUuid✔️string
返回对象类型描述原文
descriptorIdstring一个唯一标识此描述符的标识符。
ENAn identifier that uniquely represents this descriptor.

🔨BluetoothEmulation.addService

将带有 |serviceUuid| 的服务添加到地址为 |address| 的外围设备中。

EN
Adds a service with |serviceUuid| to the peripheral with |address|.
参数必填标记类型描述原文
address✔️string
serviceUuid✔️string
返回对象类型描述原文
serviceIdstring唯一标识此服务的标识符。
ENAn identifier that uniquely represents this service.

🔨BluetoothEmulation.disable

禁用BluetoothEmulation域。

EN
Disable the BluetoothEmulation domain.

🔨BluetoothEmulation.enable

启用BluetoothEmulation域。

EN
Enable the BluetoothEmulation domain.
参数必填标记类型描述原文
state✔️CentralState模拟中心的状态。
ENState of the simulated central.
leSupported✔️boolean如果模拟中心支持低功耗。
ENIf the simulated central supports low-energy.

🔨BluetoothEmulation.removeCharacteristic

从模拟中央设备中移除由 |characteristicId| 所代表的特性。

EN
Removes the characteristic respresented by |characteristicId| from the simulated central.
参数必填标记类型描述原文
characteristicId✔️string

🔨BluetoothEmulation.removeDescriptor

从模拟中央设备中移除具有 |descriptorId| 的描述符。

EN
Removes the descriptor with |descriptorId| from the simulated central.
参数必填标记类型描述原文
descriptorId✔️string

🔨BluetoothEmulation.removeService

从模拟中心移除由 |serviceId| 表示的服务。

EN
Removes the service respresented by |serviceId| from the simulated central.
参数必填标记类型描述原文
serviceId✔️string

🔨BluetoothEmulation.setSimulatedCentralState

设置模拟中央的状态。

EN
Set the state of the simulated central.
参数必填标记类型描述原文
state✔️CentralState模拟中央的状态。
ENState of the simulated central.

🔨BluetoothEmulation.simulateAdvertisement

模拟一个由中央接收到的广告数据包,该数据包在 |entry| 中有描述。

EN
Simulates an advertisement packet described in |entry| being received by the central.
参数必填标记类型描述原文
entry✔️ScanEntry

🔨BluetoothEmulation.simulateCharacteristicOperationResponse

模拟来自特性操作 |type| 中具有 |characteristicId| 的特性的响应。|code| 值遵循蓝牙核心规范卷 3 第 F 部分 3.4.1.1 错误响应中的错误代码。在模拟成功的读取操作响应时,|data| 应当存在。

EN
Simulates the response from the characteristic with |characteristicId| for a characteristic operation of |type|. The |code| value follows the Error Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response. The |data| is expected to exist when simulating a successful read operation response.
参数必填标记类型描述原文
characteristicId✔️string
type✔️CharacteristicOperationType
code✔️integer
datastring

🔨BluetoothEmulation.simulateDescriptorOperationResponse

模拟针对类型为|type|的描述符操作,使用描述符ID |descriptorId|的响应。|code|值遵循蓝牙核心规范第3卷F部分3.4.1.1章节的错误代码定义。在模拟成功的读取操作响应时,|data|应当存在。

EN
Simulates the response from the descriptor with |descriptorId| for a descriptor operation of |type|. The |code| value follows the Error Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response. The |data| is expected to exist when simulating a successful read operation response.
参数必填标记类型描述原文
descriptorId✔️string
type✔️DescriptorOperationType
code✔️integer
datastring

🔨BluetoothEmulation.simulateGATTDisconnection

模拟从地址为 |address| 的外围设备断开 GATT 连接。

EN
Simulates a GATT disconnection from the peripheral with |address|.
参数必填标记类型描述原文
address✔️string

🔨BluetoothEmulation.simulateGATTOperationResponse

模拟来自外围设备地址为|address|的GATT操作类型为|type|的响应代码。|code|值遵循蓝牙核心规范第2卷第D部分1.3节错误代码列表中的HCI错误代码。

EN
Simulates the response code from the peripheral with |address| for a GATT operation of |type|. The |code| value follows the HCI Error Codes from Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes.
参数必填标记类型描述原文
address✔️string
type✔️GATTOperationType
code✔️integer

🔨BluetoothEmulation.simulatePreconnectedPeripheral

模拟一个已连接到系统的外围设备,其地址为 |address|,名称为 |name|,已知服务 UUID 为 |knownServiceUuids|。

EN
Simulates a peripheral with |address|, |name| and |knownServiceUuids| that has already been connected to the system.
参数必填标记类型描述原文
address✔️string
name✔️string
manufacturerData✔️array[ManufacturerData]
knownServiceUuids✔️array[string]

✅️️ Events

👋BluetoothEmulation.characteristicOperationReceived

当对由 |characteristicId| 表示的蓝牙特征值执行 |type| 类型的特征操作时触发的事件。当 |type| 为写入操作时,预期会存在 |data| 和 |writeType| 参数。

EN
Event for when a characteristic operation of |type| to the characteristic respresented by |characteristicId| happened. |data| and |writeType| is expected to exist when |type| is write.
参数必填标记类型描述原文
characteristicId✔️string
type✔️CharacteristicOperationType
datastring
writeTypeCharacteristicWriteType

👋BluetoothEmulation.descriptorOperationReceived

当对由|descriptorId|表示的描述符执行|type|类型的描述符操作时发生的事件。当|type|为写入时,预期|data|存在。

EN
Event for when a descriptor operation of |type| to the descriptor respresented by |descriptorId| happened. |data| is expected to exist when |type| is write.
参数必填标记类型描述原文
descriptorId✔️string
type✔️DescriptorOperationType
datastring

👋BluetoothEmulation.gattOperationReceived

当与地址为|address|的外围设备发生|type|类型的GATT操作时触发的事件。

EN
Event for when a GATT operation of |type| to the peripheral with |address| happened.
参数必填标记类型描述原文
address✔️string
type✔️GATTOperationType

✅️️ Types

📌BluetoothEmulation.CentralState

表示Central的各种状态。
允许值:absentpowered-offpowered-on

EN
Indicates the various states of Central.
Allowed Values: absent, powered-off, powered-on

返回类型:string


📌BluetoothEmulation.CharacteristicOperationType

表示不同类型的特征操作。
允许的值:readwritesubscribe-to-notificationsunsubscribe-from-notifications

EN
Indicates the various types of characteristic operation.
Allowed Values: read, write, subscribe-to-notifications, unsubscribe-from-notifications

返回类型:string


📌BluetoothEmulation.CharacteristicProperties

描述一个特性的属性。这遵循蓝牙核心规范 BT 4.2 Vol 3 Part G 3.3.1. 特性属性。

EN
Describes the properties of a characteristic. This follows Bluetooth Core Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.

返回类型:object

属性必填标记类型描述原文
broadcastboolean
readboolean
writeWithoutResponseboolean
writeboolean
notifyboolean
indicateboolean
authenticatedSignedWritesboolean
extendedPropertiesboolean

📌BluetoothEmulation.CharacteristicWriteType

指示不同类型的特征写入操作。
允许的值:write-default-deprecatedwrite-with-responsewrite-without-response

EN
Indicates the various types of characteristic write.
Allowed Values: write-default-deprecated, write-with-response, write-without-response

返回类型:string


📌BluetoothEmulation.DescriptorOperationType

表示描述符操作的各种类型。
允许的值:readwrite

EN
Indicates the various types of descriptor operation.
Allowed Values: read, write

返回类型:string


📌BluetoothEmulation.GATTOperationType

表示GATT事件的各种类型。
允许的值:connectiondiscovery

EN
Indicates the various types of GATT event.
Allowed Values: connection, discovery

返回类型:string


📌BluetoothEmulation.ManufacturerData

存储制造商数据

EN
Stores the manufacturer data

返回类型:object

属性必填标记类型描述原文
key✔️integer公司标识符 https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yamlhttps://usb.org/developers
ENCompany identifier https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yamlhttps://usb.org/developers
data✔️string制造商特定数据(通过 JSON 传递时编码为 base64 字符串)
ENManufacturer-specific data (Encoded as a base64 string when passed over JSON)

📌BluetoothEmulation.ScanEntry

存储由蓝牙设备发送的广告数据包信息。

EN
Stores the advertisement packet information that is sent by a Bluetooth device.

返回类型:object

属性必填标记类型描述原文
deviceAddress✔️string
rssi✔️integer
scanRecord✔️ScanRecord

📌BluetoothEmulation.ScanRecord

存储蓝牙设备发送的广告数据包的字节数据。

EN
Stores the byte data of the advertisement packet sent by a Bluetooth device.

返回类型:object

属性必填标记类型描述原文
namestring
uuidsarray[string]
appearanceinteger存储设备的外部外观描述。
ENStores the external appearance description of the device.
txPowerinteger存储广播设备的传输功率。
ENStores the transmission power of a broadcasting device.
manufacturerDataarray[ManufacturerData]键是公司标识符,值是一个字节数组,包含制造商特定的数据。
ENKey is the company identifier and the value is an array of bytes of manufacturer specific data.