BluetoothEmulation#
This domain allows configuring virtual Bluetooth devices to test the web-bluetooth API.
This CDP domain is experimental.
Types#
Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.
- class CentralState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Indicates the various states of Central.
- ABSENT = 'absent'#
- POWERED_OFF = 'powered-off'#
- POWERED_ON = 'powered-on'#
- class GATTOperationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Indicates the various types of GATT event.
- CONNECTION = 'connection'#
- DISCOVERY = 'discovery'#
- class CharacteristicWriteType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Indicates the various types of characteristic write.
- WRITE_DEFAULT_DEPRECATED = 'write-default-deprecated'#
- WRITE_WITH_RESPONSE = 'write-with-response'#
- WRITE_WITHOUT_RESPONSE = 'write-without-response'#
- class CharacteristicOperationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Indicates the various types of characteristic operation.
- READ = 'read'#
- WRITE = 'write'#
- SUBSCRIBE_TO_NOTIFICATIONS = 'subscribe-to-notifications'#
- UNSUBSCRIBE_FROM_NOTIFICATIONS = 'unsubscribe-from-notifications'#
- class DescriptorOperationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Indicates the various types of descriptor operation.
- READ = 'read'#
- WRITE = 'write'#
- class ManufacturerData(key, data)[source]#
Stores the manufacturer data
- class ScanRecord(name=None, uuids=None, appearance=None, tx_power=None, manufacturer_data=None)[source]#
Stores the byte data of the advertisement packet sent by a Bluetooth device.
-
manufacturer_data:
Optional[List[ManufacturerData]] = None# Key is the company identifier and the value is an array of bytes of manufacturer specific data.
-
manufacturer_data:
- class ScanEntry(device_address, rssi, scan_record)[source]#
Stores the advertisement packet information that is sent by a Bluetooth device.
-
scan_record:
ScanRecord#
-
scan_record:
- class CharacteristicProperties(broadcast=None, read=None, write_without_response=None, write=None, notify=None, indicate=None, authenticated_signed_writes=None, extended_properties=None)[source]#
Describes the properties of a characteristic. This follows Bluetooth Core Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.
Commands#
Each command is a generator function. The return
type Generator[x, y, z] indicates that the generator
yields arguments of type x, it must be resumed with
an argument of type y, and it returns type z. In
this library, types x and y are the same for all
commands, and z is the return type you should pay attention
to. For more information, see
Getting Started: Commands.
- add_characteristic(service_id, characteristic_uuid, properties)[source]#
Adds a characteristic with
characteristicUuidandpropertiesto the service represented byserviceId.
- add_descriptor(characteristic_id, descriptor_uuid)[source]#
Adds a descriptor with
descriptorUuidto the characteristic respresented bycharacteristicId.
- add_service(address, service_uuid)[source]#
Adds a service with
serviceUuidto the peripheral withaddress.
- remove_characteristic(characteristic_id)[source]#
Removes the characteristic respresented by
characteristicIdfrom the simulated central.
- remove_descriptor(descriptor_id)[source]#
Removes the descriptor with
descriptorIdfrom the simulated central.
- remove_service(service_id)[source]#
Removes the service respresented by
serviceIdfrom the simulated central.
- simulate_advertisement(entry)[source]#
Simulates an advertisement packet described in
entrybeing received by the central.
- simulate_characteristic_operation_response(characteristic_id, type_, code, data=None)[source]#
Simulates the response from the characteristic with
characteristicIdfor a characteristic operation oftype. Thecodevalue follows the Error Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response. Thedatais expected to exist when simulating a successful read operation response.
- simulate_descriptor_operation_response(descriptor_id, type_, code, data=None)[source]#
Simulates the response from the descriptor with
descriptorIdfor a descriptor operation oftype. Thecodevalue follows the Error Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response. Thedatais expected to exist when simulating a successful read operation response.
- simulate_gatt_disconnection(address)[source]#
Simulates a GATT disconnection from the peripheral with
address.
- simulate_gatt_operation_response(address, type_, code)[source]#
Simulates the response code from the peripheral with
addressfor a GATT operation oftype. Thecodevalue follows the HCI Error Codes from Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes.
Events#
Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.
- class GattOperationReceived(address, type_)[source]#
Event for when a GATT operation of
typeto the peripheral withaddresshappened.-
type_:
GATTOperationType#
-
type_:
- class CharacteristicOperationReceived(characteristic_id, type_, data, write_type)[source]#
Event for when a characteristic operation of
typeto the characteristic respresented bycharacteristicIdhappened.dataandwriteTypeis expected to exist whentypeis write.-
type_:
CharacteristicOperationType#
-
write_type:
Optional[CharacteristicWriteType]#
-
type_: