bluetoothemulation

package
v0.157.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bluetoothemulation provides the Chrome DevTools Protocol commands, types, and events for the BluetoothEmulation domain.

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

Generated by the cdproto-gen command.

Index

Constants

View Source
const (
	CommandEnable                                  = "BluetoothEmulation.enable"
	CommandSetSimulatedCentralState                = "BluetoothEmulation.setSimulatedCentralState"
	CommandDisable                                 = "BluetoothEmulation.disable"
	CommandSimulatePreconnectedPeripheral          = "BluetoothEmulation.simulatePreconnectedPeripheral"
	CommandSimulateAdvertisement                   = "BluetoothEmulation.simulateAdvertisement"
	CommandSimulateGATTOperationResponse           = "BluetoothEmulation.simulateGATTOperationResponse"
	CommandSimulateCharacteristicOperationResponse = "BluetoothEmulation.simulateCharacteristicOperationResponse"
	CommandSimulateDescriptorOperationResponse     = "BluetoothEmulation.simulateDescriptorOperationResponse"
	CommandAddService                              = "BluetoothEmulation.addService"
	CommandRemoveService                           = "BluetoothEmulation.removeService"
	CommandAddCharacteristic                       = "BluetoothEmulation.addCharacteristic"
	CommandRemoveCharacteristic                    = "BluetoothEmulation.removeCharacteristic"
	CommandAddDescriptor                           = "BluetoothEmulation.addDescriptor"
	CommandRemoveDescriptor                        = "BluetoothEmulation.removeDescriptor"
	CommandSimulateGATTDisconnection               = "BluetoothEmulation.simulateGATTDisconnection"
)

Command names.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddCharacteristicParams

type AddCharacteristicParams struct {
	ServiceID          string                    `json:"serviceId"`
	CharacteristicUUID string                    `json:"characteristicUuid"`
	Properties         *CharacteristicProperties `json:"properties"`
}

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

func AddCharacteristic

func AddCharacteristic(serviceID string, characteristicUUID string, properties *CharacteristicProperties) *AddCharacteristicParams

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addCharacteristic

parameters:

serviceID
characteristicUUID
properties

func (*AddCharacteristicParams) Do

func (p *AddCharacteristicParams) Do(ctx context.Context) (characteristicID string, err error)

Do executes BluetoothEmulation.addCharacteristic against the provided context.

returns:

characteristicID - An identifier that uniquely represents this characteristic.

type AddCharacteristicReturns

type AddCharacteristicReturns struct {
	CharacteristicID string `json:"characteristicId,omitempty,omitzero"` // An identifier that uniquely represents this characteristic.
}

AddCharacteristicReturns return values.

type AddDescriptorParams

type AddDescriptorParams struct {
	CharacteristicID string `json:"characteristicId"`
	DescriptorUUID   string `json:"descriptorUuid"`
}

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

func AddDescriptor

func AddDescriptor(characteristicID string, descriptorUUID string) *AddDescriptorParams

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addDescriptor

parameters:

characteristicID
descriptorUUID

func (*AddDescriptorParams) Do

func (p *AddDescriptorParams) Do(ctx context.Context) (descriptorID string, err error)

Do executes BluetoothEmulation.addDescriptor against the provided context.

returns:

descriptorID - An identifier that uniquely represents this descriptor.

type AddDescriptorReturns

type AddDescriptorReturns struct {
	DescriptorID string `json:"descriptorId,omitempty,omitzero"` // An identifier that uniquely represents this descriptor.
}

AddDescriptorReturns return values.

type AddServiceParams

type AddServiceParams struct {
	Address     string `json:"address"`
	ServiceUUID string `json:"serviceUuid"`
}

AddServiceParams adds a service with |serviceUuid| to the peripheral with |address|.

func AddService

func AddService(address string, serviceUUID string) *AddServiceParams

AddService adds a service with |serviceUuid| to the peripheral with |address|.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addService

parameters:

address
serviceUUID

func (*AddServiceParams) Do

func (p *AddServiceParams) Do(ctx context.Context) (serviceID string, err error)

Do executes BluetoothEmulation.addService against the provided context.

returns:

serviceID - An identifier that uniquely represents this service.

type AddServiceReturns

type AddServiceReturns struct {
	ServiceID string `json:"serviceId,omitempty,omitzero"` // An identifier that uniquely represents this service.
}

AddServiceReturns return values.

type CentralState

type CentralState string

CentralState indicates the various states of Central.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-CentralState

const (
	CentralStateAbsent     CentralState = "absent"
	CentralStatePoweredOff CentralState = "powered-off"
	CentralStatePoweredOn  CentralState = "powered-on"
)

CentralState values.

func (CentralState) String

func (t CentralState) String() string

String returns the CentralState as string value.

func (*CentralState) UnmarshalJSON

func (t *CentralState) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies [json.Unmarshaler].

type CharacteristicOperationType

type CharacteristicOperationType string

CharacteristicOperationType indicates the various types of characteristic operation.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-CharacteristicOperationType

const (
	CharacteristicOperationTypeRead                         CharacteristicOperationType = "read"
	CharacteristicOperationTypeWrite                        CharacteristicOperationType = "write"
	CharacteristicOperationTypeSubscribeToNotifications     CharacteristicOperationType = "subscribe-to-notifications"
	CharacteristicOperationTypeUnsubscribeFromNotifications CharacteristicOperationType = "unsubscribe-from-notifications"
)

CharacteristicOperationType values.

func (CharacteristicOperationType) String

String returns the CharacteristicOperationType as string value.

func (*CharacteristicOperationType) UnmarshalJSON

func (t *CharacteristicOperationType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies [json.Unmarshaler].

type CharacteristicProperties

type CharacteristicProperties struct {
	Broadcast                 bool `json:"broadcast"`
	Read                      bool `json:"read"`
	WriteWithoutResponse      bool `json:"writeWithoutResponse"`
	Write                     bool `json:"write"`
	Notify                    bool `json:"notify"`
	Indicate                  bool `json:"indicate"`
	AuthenticatedSignedWrites bool `json:"authenticatedSignedWrites"`
	ExtendedProperties        bool `json:"extendedProperties"`
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-CharacteristicProperties

type CharacteristicWriteType

type CharacteristicWriteType string

CharacteristicWriteType indicates the various types of characteristic write.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-CharacteristicWriteType

const (
	CharacteristicWriteTypeWriteDefaultDeprecated CharacteristicWriteType = "write-default-deprecated"
	CharacteristicWriteTypeWriteWithResponse      CharacteristicWriteType = "write-with-response"
	CharacteristicWriteTypeWriteWithoutResponse   CharacteristicWriteType = "write-without-response"
)

CharacteristicWriteType values.

func (CharacteristicWriteType) String

func (t CharacteristicWriteType) String() string

String returns the CharacteristicWriteType as string value.

func (*CharacteristicWriteType) UnmarshalJSON

func (t *CharacteristicWriteType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies [json.Unmarshaler].

type DescriptorOperationType

type DescriptorOperationType string

DescriptorOperationType indicates the various types of descriptor operation.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-DescriptorOperationType

const (
	DescriptorOperationTypeRead  DescriptorOperationType = "read"
	DescriptorOperationTypeWrite DescriptorOperationType = "write"
)

DescriptorOperationType values.

func (DescriptorOperationType) String

func (t DescriptorOperationType) String() string

String returns the DescriptorOperationType as string value.

func (*DescriptorOperationType) UnmarshalJSON

func (t *DescriptorOperationType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies [json.Unmarshaler].

type DisableParams

type DisableParams struct{}

DisableParams disable the BluetoothEmulation domain.

func Disable

func Disable() *DisableParams

Disable disable the BluetoothEmulation domain.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-disable

func (*DisableParams) Do

func (p *DisableParams) Do(ctx context.Context) (err error)

Do executes BluetoothEmulation.disable against the provided context.

type EnableParams

type EnableParams struct {
	State       CentralState `json:"state"`       // State of the simulated central.
	LeSupported bool         `json:"leSupported"` // If the simulated central supports low-energy.
}

EnableParams enable the BluetoothEmulation domain.

func Enable

func Enable(state CentralState, leSupported bool) *EnableParams

Enable enable the BluetoothEmulation domain.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-enable

parameters:

state - State of the simulated central.
leSupported - If the simulated central supports low-energy.

func (*EnableParams) Do

func (p *EnableParams) Do(ctx context.Context) (err error)

Do executes BluetoothEmulation.enable against the provided context.

type EventCharacteristicOperationReceived

type EventCharacteristicOperationReceived struct {
	CharacteristicID string                      `json:"characteristicId"`
	Type             CharacteristicOperationType `json:"type"`
	Data             string                      `json:"data,omitempty,omitzero"`
	WriteType        CharacteristicWriteType     `json:"writeType,omitempty,omitzero"`
}

EventCharacteristicOperationReceived 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.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#event-characteristicOperationReceived

type EventDescriptorOperationReceived

type EventDescriptorOperationReceived struct {
	DescriptorID string                  `json:"descriptorId"`
	Type         DescriptorOperationType `json:"type"`
	Data         string                  `json:"data,omitempty,omitzero"`
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#event-descriptorOperationReceived

type EventGattOperationReceived

type EventGattOperationReceived struct {
	Address string            `json:"address"`
	Type    GATTOperationType `json:"type"`
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#event-gattOperationReceived

type GATTOperationType

type GATTOperationType string

GATTOperationType indicates the various types of GATT event.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-GATTOperationType

const (
	GATTOperationTypeConnection GATTOperationType = "connection"
	GATTOperationTypeDiscovery  GATTOperationType = "discovery"
)

GATTOperationType values.

func (GATTOperationType) String

func (t GATTOperationType) String() string

String returns the GATTOperationType as string value.

func (*GATTOperationType) UnmarshalJSON

func (t *GATTOperationType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies [json.Unmarshaler].

type ManufacturerData

type ManufacturerData struct {
	Key  int64  `json:"key"`  // Company identifier https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yaml https://usb.org/developers
	Data string `json:"data"` // Manufacturer-specific data
}

ManufacturerData stores the manufacturer data.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-ManufacturerData

type RemoveCharacteristicParams

type RemoveCharacteristicParams struct {
	CharacteristicID string `json:"characteristicId"`
}

RemoveCharacteristicParams removes the characteristic respresented by |characteristicId| from the simulated central.

func RemoveCharacteristic

func RemoveCharacteristic(characteristicID string) *RemoveCharacteristicParams

RemoveCharacteristic removes the characteristic respresented by |characteristicId| from the simulated central.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeCharacteristic

parameters:

characteristicID

func (*RemoveCharacteristicParams) Do

Do executes BluetoothEmulation.removeCharacteristic against the provided context.

type RemoveDescriptorParams

type RemoveDescriptorParams struct {
	DescriptorID string `json:"descriptorId"`
}

RemoveDescriptorParams removes the descriptor with |descriptorId| from the simulated central.

func RemoveDescriptor

func RemoveDescriptor(descriptorID string) *RemoveDescriptorParams

RemoveDescriptor removes the descriptor with |descriptorId| from the simulated central.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeDescriptor

parameters:

descriptorID

func (*RemoveDescriptorParams) Do

func (p *RemoveDescriptorParams) Do(ctx context.Context) (err error)

Do executes BluetoothEmulation.removeDescriptor against the provided context.

type RemoveServiceParams

type RemoveServiceParams struct {
	ServiceID string `json:"serviceId"`
}

RemoveServiceParams removes the service respresented by |serviceId| from the simulated central.

func RemoveService

func RemoveService(serviceID string) *RemoveServiceParams

RemoveService removes the service respresented by |serviceId| from the simulated central.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeService

parameters:

serviceID

func (*RemoveServiceParams) Do

func (p *RemoveServiceParams) Do(ctx context.Context) (err error)

Do executes BluetoothEmulation.removeService against the provided context.

type ScanEntry

type ScanEntry struct {
	DeviceAddress string      `json:"deviceAddress"`
	Rssi          int64       `json:"rssi"`
	ScanRecord    *ScanRecord `json:"scanRecord"`
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-ScanEntry

type ScanRecord

type ScanRecord struct {
	Name             string              `json:"name,omitempty,omitzero"`
	UUIDs            []string            `json:"uuids,omitempty,omitzero"`
	Appearance       int64               `json:"appearance,omitempty,omitzero"`       // Stores the external appearance description of the device.
	TxPower          int64               `json:"txPower,omitempty,omitzero"`          // Stores the transmission power of a broadcasting device.
	ManufacturerData []*ManufacturerData `json:"manufacturerData,omitempty,omitzero"` // Key is the company identifier and the value is an array of bytes of manufacturer specific data.
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#type-ScanRecord

type SetSimulatedCentralStateParams

type SetSimulatedCentralStateParams struct {
	State CentralState `json:"state"` // State of the simulated central.
}

SetSimulatedCentralStateParams set the state of the simulated central.

func SetSimulatedCentralState

func SetSimulatedCentralState(state CentralState) *SetSimulatedCentralStateParams

SetSimulatedCentralState set the state of the simulated central.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-setSimulatedCentralState

parameters:

state - State of the simulated central.

func (*SetSimulatedCentralStateParams) Do

Do executes BluetoothEmulation.setSimulatedCentralState against the provided context.

type SimulateAdvertisementParams

type SimulateAdvertisementParams struct {
	Entry *ScanEntry `json:"entry"`
}

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

func SimulateAdvertisement

func SimulateAdvertisement(entry *ScanEntry) *SimulateAdvertisementParams

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateAdvertisement

parameters:

entry

func (*SimulateAdvertisementParams) Do

Do executes BluetoothEmulation.simulateAdvertisement against the provided context.

type SimulateCharacteristicOperationResponseParams

type SimulateCharacteristicOperationResponseParams struct {
	CharacteristicID string                      `json:"characteristicId"`
	Type             CharacteristicOperationType `json:"type"`
	Code             int64                       `json:"code"`
	Data             string                      `json:"data,omitempty,omitzero"`
}

SimulateCharacteristicOperationResponseParams 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.

func SimulateCharacteristicOperationResponse

func SimulateCharacteristicOperationResponse(characteristicID string, typeVal CharacteristicOperationType, code int64) *SimulateCharacteristicOperationResponseParams

SimulateCharacteristicOperationResponse 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.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateCharacteristicOperationResponse

parameters:

characteristicID
type
code

func (*SimulateCharacteristicOperationResponseParams) Do

Do executes BluetoothEmulation.simulateCharacteristicOperationResponse against the provided context.

func (SimulateCharacteristicOperationResponseParams) WithData

WithData [no description].

type SimulateDescriptorOperationResponseParams

type SimulateDescriptorOperationResponseParams struct {
	DescriptorID string                  `json:"descriptorId"`
	Type         DescriptorOperationType `json:"type"`
	Code         int64                   `json:"code"`
	Data         string                  `json:"data,omitempty,omitzero"`
}

SimulateDescriptorOperationResponseParams 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.

func SimulateDescriptorOperationResponse

func SimulateDescriptorOperationResponse(descriptorID string, typeVal DescriptorOperationType, code int64) *SimulateDescriptorOperationResponseParams

SimulateDescriptorOperationResponse 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.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateDescriptorOperationResponse

parameters:

descriptorID
type
code

func (*SimulateDescriptorOperationResponseParams) Do

Do executes BluetoothEmulation.simulateDescriptorOperationResponse against the provided context.

func (SimulateDescriptorOperationResponseParams) WithData

WithData [no description].

type SimulateGATTDisconnectionParams

type SimulateGATTDisconnectionParams struct {
	Address string `json:"address"`
}

SimulateGATTDisconnectionParams simulates a GATT disconnection from the peripheral with |address|.

func SimulateGATTDisconnection

func SimulateGATTDisconnection(address string) *SimulateGATTDisconnectionParams

SimulateGATTDisconnection simulates a GATT disconnection from the peripheral with |address|.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateGATTDisconnection

parameters:

address

func (*SimulateGATTDisconnectionParams) Do

Do executes BluetoothEmulation.simulateGATTDisconnection against the provided context.

type SimulateGATTOperationResponseParams

type SimulateGATTOperationResponseParams struct {
	Address string            `json:"address"`
	Type    GATTOperationType `json:"type"`
	Code    int64             `json:"code"`
}

SimulateGATTOperationResponseParams 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.

func SimulateGATTOperationResponse

func SimulateGATTOperationResponse(address string, typeVal GATTOperationType, code int64) *SimulateGATTOperationResponseParams

SimulateGATTOperationResponse 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.

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateGATTOperationResponse

parameters:

address
type
code

func (*SimulateGATTOperationResponseParams) Do

Do executes BluetoothEmulation.simulateGATTOperationResponse against the provided context.

type SimulatePreconnectedPeripheralParams

type SimulatePreconnectedPeripheralParams struct {
	Address           string              `json:"address"`
	Name              string              `json:"name"`
	ManufacturerData  []*ManufacturerData `json:"manufacturerData"`
	KnownServiceUUIDs []string            `json:"knownServiceUuids"`
}

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

func SimulatePreconnectedPeripheral

func SimulatePreconnectedPeripheral(address string, name string, manufacturerData []*ManufacturerData, knownServiceUUIDs []string) *SimulatePreconnectedPeripheralParams

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

See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulatePreconnectedPeripheral

parameters:

address
name
manufacturerData
knownServiceUUIDs

func (*SimulatePreconnectedPeripheralParams) Do

Do executes BluetoothEmulation.simulatePreconnectedPeripheral against the provided context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL