BluetoothEmulation

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

Constructors

Link copied to clipboard
constructor(cdp: CDP)

Types

Link copied to clipboard
@Serializable
data class AddCharacteristicParameter(val serviceId: String, val characteristicUuid: String, val properties: BluetoothEmulation.CharacteristicProperties)
Link copied to clipboard
@Serializable
data class AddCharacteristicReturn(val characteristicId: String)
Link copied to clipboard
@Serializable
data class AddDescriptorParameter(val characteristicId: String, val descriptorUuid: String)
Link copied to clipboard
@Serializable
data class AddDescriptorReturn(val descriptorId: String)
Link copied to clipboard
@Serializable
data class AddServiceParameter(val address: String, val serviceUuid: String)
Link copied to clipboard
@Serializable
data class AddServiceReturn(val serviceId: String)
Link copied to clipboard

Indicates the various states of Central.

Link copied to clipboard
@Serializable
data class CharacteristicOperationReceivedParameter(val characteristicId: String, val type: BluetoothEmulation.CharacteristicOperationType, val data: String? = null, val writeType: BluetoothEmulation.CharacteristicWriteType? = null)

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.

Link copied to clipboard

Indicates the various types of characteristic operation.

Link copied to clipboard
@Serializable
data class CharacteristicProperties(val broadcast: Boolean? = null, val read: Boolean? = null, val writeWithoutResponse: Boolean? = null, val write: Boolean? = null, val notify: Boolean? = null, val indicate: Boolean? = null, val authenticatedSignedWrites: Boolean? = null, val extendedProperties: Boolean? = null)

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

Link copied to clipboard

Indicates the various types of characteristic write.

Link copied to clipboard
@Serializable
data class DescriptorOperationReceivedParameter(val descriptorId: String, val type: BluetoothEmulation.DescriptorOperationType, val data: String? = null)

Event for when a descriptor operation of |type| to the descriptor respresented by |descriptorId| happened. |data| is expected to exist when |type| is write.

Link copied to clipboard

Indicates the various types of descriptor operation.

Link copied to clipboard
@Serializable
data class EnableParameter(val state: BluetoothEmulation.CentralState, val leSupported: Boolean)
Link copied to clipboard
@Serializable
data class GattOperationReceivedParameter(val address: String, val type: BluetoothEmulation.GATTOperationType)

Event for when a GATT operation of |type| to the peripheral with |address| happened.

Link copied to clipboard

Indicates the various types of GATT event.

Link copied to clipboard
@Serializable
data class ManufacturerData(val key: Int, val data: String)

Stores the manufacturer data

Link copied to clipboard
@Serializable
data class RemoveCharacteristicParameter(val characteristicId: String)
Link copied to clipboard
@Serializable
data class RemoveDescriptorParameter(val descriptorId: String)
Link copied to clipboard
@Serializable
data class RemoveServiceParameter(val serviceId: String)
Link copied to clipboard
@Serializable
data class ScanEntry(val deviceAddress: String, val rssi: Int, val scanRecord: BluetoothEmulation.ScanRecord)

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

Link copied to clipboard
@Serializable
data class ScanRecord(val name: String? = null, val uuids: List<String>? = null, val appearance: Int? = null, val txPower: Int? = null, val manufacturerData: List<BluetoothEmulation.ManufacturerData>? = null)

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

Link copied to clipboard
Link copied to clipboard
@Serializable
data class SimulateCharacteristicOperationResponseParameter(val characteristicId: String, val type: BluetoothEmulation.CharacteristicOperationType, val code: Int, val data: String? = null)
@Serializable
data class SimulateDescriptorOperationResponseParameter(val descriptorId: String, val type: BluetoothEmulation.DescriptorOperationType, val code: Int, val data: String? = null)
Link copied to clipboard
@Serializable
data class SimulateGATTDisconnectionParameter(val address: String)
Link copied to clipboard
@Serializable
data class SimulateGATTOperationResponseParameter(val address: String, val type: BluetoothEmulation.GATTOperationType, val code: Int)
Link copied to clipboard
@Serializable
data class SimulatePreconnectedPeripheralParameter(val address: String, val name: String, val manufacturerData: List<BluetoothEmulation.ManufacturerData>, val knownServiceUuids: List<String>)

Properties

Link copied to clipboard

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.

Link copied to clipboard

Event for when a descriptor operation of |type| to the descriptor respresented by |descriptorId| happened. |data| is expected to exist when |type| is write.

Link copied to clipboard

Event for when a GATT operation of |type| to the peripheral with |address| happened.

Functions

Link copied to clipboard

Adds a characteristic with |characteristicUuid| and |properties| to the service represented by |serviceId|.

Link copied to clipboard
suspend fun addDescriptor(characteristicId: String, descriptorUuid: String): BluetoothEmulation.AddDescriptorReturn

Adds a descriptor with |descriptorUuid| to the characteristic respresented by |characteristicId|.

Link copied to clipboard
suspend fun addService(address: String, serviceUuid: String): BluetoothEmulation.AddServiceReturn

Adds a service with |serviceUuid| to the peripheral with |address|.

Link copied to clipboard
suspend fun disable(mode: CommandMode = CommandMode.DEFAULT)

Disable the BluetoothEmulation domain.

Link copied to clipboard
suspend fun enable(state: BluetoothEmulation.CentralState, leSupported: Boolean)
suspend fun enable(args: BluetoothEmulation.EnableParameter, mode: CommandMode = CommandMode.DEFAULT)

Enable the BluetoothEmulation domain.

Link copied to clipboard
suspend fun removeCharacteristic(characteristicId: String)

Removes the characteristic respresented by |characteristicId| from the simulated central.

Link copied to clipboard
suspend fun removeDescriptor(descriptorId: String)
suspend fun removeDescriptor(args: BluetoothEmulation.RemoveDescriptorParameter, mode: CommandMode = CommandMode.DEFAULT)

Removes the descriptor with |descriptorId| from the simulated central.

Link copied to clipboard
suspend fun removeService(serviceId: String)
suspend fun removeService(args: BluetoothEmulation.RemoveServiceParameter, mode: CommandMode = CommandMode.DEFAULT)

Removes the service respresented by |serviceId| from the simulated central.

Link copied to clipboard

Set the state of the simulated central.

Link copied to clipboard

Simulates an advertisement packet described in |entry| being received by the central.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard
suspend fun simulateGATTDisconnection(address: String)

Simulates a GATT disconnection from the peripheral with |address|.

Link copied to clipboard

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.

Link copied to clipboard
suspend fun simulatePreconnectedPeripheral(address: String, name: String, manufacturerData: List<BluetoothEmulation.ManufacturerData>, knownServiceUuids: List<String>)

Simulates a peripheral with |address|, |name| and |knownServiceUuids| that has already been connected to the system.