bluetooth_emulation
CentralState
Bases: Enum
Indicates the various states of Central.
Source code in zendriver/cdp/bluetooth_emulation.py
ABSENT = 'absent'
class-attribute
instance-attribute
POWERED_OFF = 'powered-off'
class-attribute
instance-attribute
POWERED_ON = 'powered-on'
class-attribute
instance-attribute
from_json(json)
classmethod
CharacteristicOperationReceived
dataclass
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.
Source code in zendriver/cdp/bluetooth_emulation.py
characteristic_id: str
instance-attribute
data: typing.Optional[str]
instance-attribute
type_: CharacteristicOperationType
instance-attribute
write_type: typing.Optional[CharacteristicWriteType]
instance-attribute
__init__(characteristic_id, type_, data, write_type)
from_json(json)
classmethod
Source code in zendriver/cdp/bluetooth_emulation.py
CharacteristicOperationType
Bases: Enum
Indicates the various types of characteristic operation.
Source code in zendriver/cdp/bluetooth_emulation.py
READ = 'read'
class-attribute
instance-attribute
SUBSCRIBE_TO_NOTIFICATIONS = 'subscribe-to-notifications'
class-attribute
instance-attribute
UNSUBSCRIBE_FROM_NOTIFICATIONS = 'unsubscribe-from-notifications'
class-attribute
instance-attribute
WRITE = 'write'
class-attribute
instance-attribute
from_json(json)
classmethod
CharacteristicProperties
dataclass
Describes the properties of a characteristic. This follows Bluetooth Core Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.
Source code in zendriver/cdp/bluetooth_emulation.py
authenticated_signed_writes: typing.Optional[bool] = None
class-attribute
instance-attribute
broadcast: typing.Optional[bool] = None
class-attribute
instance-attribute
extended_properties: typing.Optional[bool] = None
class-attribute
instance-attribute
indicate: typing.Optional[bool] = None
class-attribute
instance-attribute
notify: typing.Optional[bool] = None
class-attribute
instance-attribute
read: typing.Optional[bool] = None
class-attribute
instance-attribute
write: typing.Optional[bool] = None
class-attribute
instance-attribute
write_without_response: typing.Optional[bool] = None
class-attribute
instance-attribute
__init__(broadcast=None, read=None, write_without_response=None, write=None, notify=None, indicate=None, authenticated_signed_writes=None, extended_properties=None)
from_json(json)
classmethod
Source code in zendriver/cdp/bluetooth_emulation.py
to_json()
Source code in zendriver/cdp/bluetooth_emulation.py
CharacteristicWriteType
Bases: Enum
Indicates the various types of characteristic write.
Source code in zendriver/cdp/bluetooth_emulation.py
WRITE_DEFAULT_DEPRECATED = 'write-default-deprecated'
class-attribute
instance-attribute
WRITE_WITHOUT_RESPONSE = 'write-without-response'
class-attribute
instance-attribute
WRITE_WITH_RESPONSE = 'write-with-response'
class-attribute
instance-attribute
from_json(json)
classmethod
DescriptorOperationReceived
dataclass
Event for when a descriptor operation of type
to the descriptor
respresented by descriptorId
happened. data
is expected to exist when
type
is write.
Source code in zendriver/cdp/bluetooth_emulation.py
data: typing.Optional[str]
instance-attribute
descriptor_id: str
instance-attribute
type_: CharacteristicOperationType
instance-attribute
__init__(descriptor_id, type_, data)
from_json(json)
classmethod
Source code in zendriver/cdp/bluetooth_emulation.py
DescriptorOperationType
Bases: Enum
Indicates the various types of descriptor operation.
Source code in zendriver/cdp/bluetooth_emulation.py
READ = 'read'
class-attribute
instance-attribute
WRITE = 'write'
class-attribute
instance-attribute
from_json(json)
classmethod
GATTOperationType
Bases: Enum
Indicates the various types of GATT event.
Source code in zendriver/cdp/bluetooth_emulation.py
CONNECTION = 'connection'
class-attribute
instance-attribute
DISCOVERY = 'discovery'
class-attribute
instance-attribute
from_json(json)
classmethod
GattOperationReceived
dataclass
Event for when a GATT operation of type
to the peripheral with address
happened.
Source code in zendriver/cdp/bluetooth_emulation.py
address: str
instance-attribute
type_: GATTOperationType
instance-attribute
__init__(address, type_)
ManufacturerData
dataclass
Stores the manufacturer data
Source code in zendriver/cdp/bluetooth_emulation.py
data: str
instance-attribute
key: int
instance-attribute
__init__(key, data)
from_json(json)
classmethod
ScanEntry
dataclass
Stores the advertisement packet information that is sent by a Bluetooth device.
Source code in zendriver/cdp/bluetooth_emulation.py
device_address: str
instance-attribute
rssi: int
instance-attribute
scan_record: ScanRecord
instance-attribute
__init__(device_address, rssi, scan_record)
from_json(json)
classmethod
ScanRecord
dataclass
Stores the byte data of the advertisement packet sent by a Bluetooth device.
Source code in zendriver/cdp/bluetooth_emulation.py
appearance: typing.Optional[int] = None
class-attribute
instance-attribute
manufacturer_data: typing.Optional[typing.List[ManufacturerData]] = None
class-attribute
instance-attribute
name: typing.Optional[str] = None
class-attribute
instance-attribute
tx_power: typing.Optional[int] = None
class-attribute
instance-attribute
uuids: typing.Optional[typing.List[str]] = None
class-attribute
instance-attribute
__init__(name=None, uuids=None, appearance=None, tx_power=None, manufacturer_data=None)
from_json(json)
classmethod
Source code in zendriver/cdp/bluetooth_emulation.py
to_json()
Source code in zendriver/cdp/bluetooth_emulation.py
add_characteristic(service_id, characteristic_uuid, properties)
Adds a characteristic with characteristicUuid
and properties
to the
service represented by serviceId
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_id
|
str
|
|
required |
characteristic_uuid
|
str
|
|
required |
properties
|
CharacteristicProperties
|
|
required |
Returns:
Type | Description |
---|---|
Generator[T_JSON_DICT, T_JSON_DICT, str]
|
An identifier that uniquely represents this characteristic. |
Source code in zendriver/cdp/bluetooth_emulation.py
add_descriptor(characteristic_id, descriptor_uuid)
Adds a descriptor with descriptorUuid
to the characteristic respresented
by characteristicId
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
characteristic_id
|
str
|
|
required |
descriptor_uuid
|
str
|
|
required |
Returns:
Type | Description |
---|---|
Generator[T_JSON_DICT, T_JSON_DICT, str]
|
An identifier that uniquely represents this descriptor. |
Source code in zendriver/cdp/bluetooth_emulation.py
add_service(address, service_uuid)
Adds a service with serviceUuid
to the peripheral with address
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
str
|
|
required |
service_uuid
|
str
|
|
required |
Returns:
Type | Description |
---|---|
Generator[T_JSON_DICT, T_JSON_DICT, str]
|
An identifier that uniquely represents this service. |
Source code in zendriver/cdp/bluetooth_emulation.py
disable()
Disable the BluetoothEmulation domain.
enable(state, le_supported)
Enable the BluetoothEmulation domain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
CentralState
|
State of the simulated central. |
required |
le_supported
|
bool
|
If the simulated central supports low-energy. |
required |
Source code in zendriver/cdp/bluetooth_emulation.py
remove_characteristic(characteristic_id)
Removes the characteristic respresented by characteristicId
from the
simulated central.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
characteristic_id
|
str
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
remove_descriptor(descriptor_id)
Removes the descriptor with descriptorId
from the simulated central.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
descriptor_id
|
str
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
remove_service(service_id)
Removes the service respresented by serviceId
from the simulated central.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_id
|
str
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
set_simulated_central_state(state)
Set the state of the simulated central.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
CentralState
|
State of the simulated central. |
required |
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_advertisement(entry)
Simulates an advertisement packet described in entry
being received by
the central.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
ScanEntry
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_characteristic_operation_response(characteristic_id, type_, code, data=None)
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
characteristic_id
|
str
|
|
required |
type_
|
CharacteristicOperationType
|
|
required |
code
|
int
|
|
required |
data
|
Optional[str]
|
(Optional) |
None
|
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_descriptor_operation_response(descriptor_id, type_, code, data=None)
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
descriptor_id
|
str
|
|
required |
type_
|
DescriptorOperationType
|
|
required |
code
|
int
|
|
required |
data
|
Optional[str]
|
(Optional) |
None
|
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_gatt_disconnection(address)
Simulates a GATT disconnection from the peripheral with address
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
str
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_gatt_operation_response(address, type_, code)
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
str
|
|
required |
type_
|
GATTOperationType
|
|
required |
code
|
int
|
|
required |
Source code in zendriver/cdp/bluetooth_emulation.py
simulate_preconnected_peripheral(address, name, manufacturer_data, known_service_uuids)
Simulates a peripheral with address
, name
and knownServiceUuids
that has already been connected to the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
str
|
|
required |
name
|
str
|
|
required |
manufacturer_data
|
List[ManufacturerData]
|
|
required |
known_service_uuids
|
List[str]
|
|
required |