o
    M,hH                     @  s  d dl mZ ddlmZmZ d dlmZ d dlZd dlZG dd dej	Z
G dd	 d	ej	ZG d
d dej	ZG dd dej	ZG dd dej	ZeG dd dZeG dd dZeG dd dZeG dd dZdYddZdZdd Zd[d!d"Zd\d*d+Zd]d-d.Zd^d2d3Z	d_d`d7d8Z	d_dad:d;Zdbd>d?ZdcdAdBZdddEdFZdedGdHZdfdJdKZdgdLdMZ dhdNdOZ!edPeG dQdR dRZ"edSeG dTdU dUZ#edVeG dWdX dXZ$dS )i    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  0   e Zd ZdZdZdZdZdd Zedd Z	d	S )
CentralStatez2
    Indicates the various states of Central.
    absentzpowered-offz
powered-onc                 C     | j S Nvalueself r   /var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v141/bluetooth_emulation.pyto_json      zCentralState.to_jsonc                 C     | |S r   r   clsjsonr   r   r   	from_json      zCentralState.from_jsonN)
__name__
__module____qualname____doc__ABSENTPOWERED_OFF
POWERED_ONr   classmethodr   r   r   r   r   r          r   c                   @  ,   e Zd ZdZdZdZdd Zedd ZdS )	GATTOperationTypez4
    Indicates the various types of GATT event.
    
connection	discoveryc                 C  r
   r   r   r   r   r   r   r   $   r   zGATTOperationType.to_jsonc                 C  r   r   r   r   r   r   r   r   '   r   zGATTOperationType.from_jsonN)	r   r   r   r   
CONNECTION	DISCOVERYr   r!   r   r   r   r   r   r$          r$   c                   @  r   )
CharacteristicWriteTypez>
    Indicates the various types of characteristic write.
    zwrite-default-deprecatedzwrite-with-responsezwrite-without-responsec                 C  r
   r   r   r   r   r   r   r   4   r   zCharacteristicWriteType.to_jsonc                 C  r   r   r   r   r   r   r   r   7   r   z!CharacteristicWriteType.from_jsonN)
r   r   r   r   WRITE_DEFAULT_DEPRECATEDWRITE_WITH_RESPONSEWRITE_WITHOUT_RESPONSEr   r!   r   r   r   r   r   r*   ,   r"   r*   c                   @  s4   e Zd ZdZdZdZdZdZdd Ze	dd	 Z
d
S )CharacteristicOperationTypezB
    Indicates the various types of characteristic operation.
    readwritezsubscribe-to-notificationszunsubscribe-from-notificationsc                 C  r
   r   r   r   r   r   r   r   E   r   z#CharacteristicOperationType.to_jsonc                 C  r   r   r   r   r   r   r   r   H   r   z%CharacteristicOperationType.from_jsonN)r   r   r   r   READWRITESUBSCRIBE_TO_NOTIFICATIONSUNSUBSCRIBE_FROM_NOTIFICATIONSr   r!   r   r   r   r   r   r.   <   s    r.   c                   @  r#   )	DescriptorOperationTypez>
    Indicates the various types of descriptor operation.
    r/   r0   c                 C  r
   r   r   r   r   r   r   r   T   r   zDescriptorOperationType.to_jsonc                 C  r   r   r   r   r   r   r   r   W   r   z!DescriptorOperationType.from_jsonN)	r   r   r   r   r1   r2   r   r!   r   r   r   r   r   r5   M   r)   r5   c                   @  s6   e Zd ZU dZded< ded< dd Zedd	 Zd
S )ManufacturerDataz&
    Stores the manufacturer data
    intkeystrdatac                 C  s   t  }| j|d< | j|d< |S )Nr8   r:   )dictr8   r:   r   r   r   r   r   r   i   s   

zManufacturerData.to_jsonc                 C  s   | t |d t|d dS )Nr8   r:   )r8   r:   )r7   r9   r   r   r   r   r   o   s   

zManufacturerData.from_jsonNr   r   r   r   __annotations__r   r!   r   r   r   r   r   r6   \   s   
 r6   c                   @  sb   e Zd ZU dZdZded< dZded< dZded< dZded	< dZ	d
ed< dd Z
edd ZdS )
ScanRecordzV
    Stores the byte data of the advertisement packet sent by a Bluetooth device.
    Ntyping.Optional[str]namez!typing.Optional[typing.List[str]]uuidsztyping.Optional[int]
appearancetx_powerz.typing.Optional[typing.List[ManufacturerData]]manufacturer_datac                 C  s   t  }| jd ur| j|d< | jd urdd | jD |d< | jd ur&| j|d< | jd ur0| j|d< | jd ur?dd | jD |d< |S )	NrA   c                 S     g | ]}|qS r   r   .0ir   r   r   
<listcomp>       z&ScanRecord.to_json.<locals>.<listcomp>rB   rC   txPowerc                 S     g | ]}|  qS r   r   rG   r   r   r   rJ          manufacturerData)r;   rA   rB   rC   rD   rE   r<   r   r   r   r      s   







zScanRecord.to_jsonc                 C  s   | d|v rt |d nd d|v rdd |d D nd d|v r$t|d nd d|v r/t|d nd d|v r?dd |d D d	S d d	S )
NrA   rB   c                 S  s   g | ]}t |qS r   )r9   rG   r   r   r   rJ      rO   z(ScanRecord.from_json.<locals>.<listcomp>rC   rL   rP   c                 S  s   g | ]}t |qS r   )r6   r   rG   r   r   r   rJ      s    )rA   rB   rC   rD   rE   )r9   r7   r   r   r   r   r      s   zScanRecord.from_json)r   r   r   r   rA   r>   rB   rC   rD   rE   r   r!   r   r   r   r   r   r?   w   s   
 r?   c                   @  s>   e Zd ZU dZded< ded< ded< dd	 Zed
d ZdS )	ScanEntryzY
    Stores the advertisement packet information that is sent by a Bluetooth device.
    r9   device_addressr7   rssir?   scan_recordc                 C  s,   t  }| j|d< | j|d< | j |d< |S )NdeviceAddressrS   
scanRecord)r;   rR   rS   rT   r   r<   r   r   r   r      s
   

zScanEntry.to_jsonc                 C  s(   | t |d t|d t|d dS )NrU   rS   rV   )rR   rS   rT   )r9   r7   r?   r   r   r   r   r   r      s
   

zScanEntry.from_jsonNr=   r   r   r   r   rQ      s   
 rQ   c                   @  s   e Zd ZU dZdZded< dZded< dZded< dZded< dZ	ded< dZ
ded	< dZded
< dZded< dd Zedd ZdS )CharacteristicPropertiesz
    Describes the properties of a characteristic. This follows Bluetooth Core
    Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.
    Nztyping.Optional[bool]	broadcastr/   write_without_responser0   notifyindicateauthenticated_signed_writesextended_propertiesc                 C  s   t  }| jd ur| j|d< | jd ur| j|d< | jd ur!| j|d< | jd ur+| j|d< | jd ur5| j|d< | jd ur?| j|d< | jd urI| j|d< | jd urS| j|d< |S )	NrX   r/   writeWithoutResponser0   rZ   r[   authenticatedSignedWritesextendedProperties)	r;   rX   r/   rY   r0   rZ   r[   r\   r]   r<   r   r   r   r      s$   















z CharacteristicProperties.to_jsonc                 C  s   | d|v rt |d nd d|v rt |d nd d|v r!t |d nd d|v r,t |d nd d|v r7t |d nd d|v rBt |d nd d|v rMt |d nd d|v rZt |d d	S d d	S )
NrX   r/   r^   r0   rZ   r[   r_   r`   )rX   r/   rY   r0   rZ   r[   r\   r]   )boolr   r   r   r   r      s   z"CharacteristicProperties.from_json)r   r   r   r   rX   r>   r/   rY   r0   rZ   r[   r\   r]   r   r!   r   r   r   r   r   rW      s   
 rW   statele_supportedra   return0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s0    t  }|  |d< ||d< d|d}|V }dS )z
    Enable the BluetoothEmulation domain.

    :param state: State of the simulated central.
    :param le_supported: If the simulated central supports low-energy.
    rb   leSupportedzBluetoothEmulation.enablemethodparamsNr;   r   )rb   rc   ri   cmd_dictr   r   r   r   enable   s   

rl   c                 c  (    t  }|  |d< d|d}|V }dS )zd
    Set the state of the simulated central.

    :param state: State of the simulated central.
    rb   z+BluetoothEmulation.setSimulatedCentralStaterg   Nrj   )rb   ri   rk   r   r   r   r   set_simulated_central_state
  s   
rn   c                  c  s    ddi} | V }dS )z0
    Disable the BluetoothEmulation domain.
    rh   zBluetoothEmulation.disableNr   )rk   r   r   r   r   disable  s   
ro   addressr9   rA   rE   typing.List[ManufacturerData]known_service_uuidstyping.List[str]c                 c  sP    t  }| |d< ||d< dd |D |d< dd |D |d< d|d	}|V }d
S )z
    Simulates a peripheral with ``address``, ``name`` and ``knownServiceUuids``
    that has already been connected to the system.

    :param address:
    :param name:
    :param manufacturer_data:
    :param known_service_uuids:
    rp   rA   c                 S  rM   r   rN   rG   r   r   r   rJ   7  rO   z4simulate_preconnected_peripheral.<locals>.<listcomp>rP   c                 S  rF   r   r   rG   r   r   r   rJ   8  rK   knownServiceUuidsz1BluetoothEmulation.simulatePreconnectedPeripheralrg   Nr;   )rp   rA   rE   rr   ri   rk   r   r   r   r    simulate_preconnected_peripheral%  s   
rv   entryc                 c  rm   )zx
    Simulates an advertisement packet described in ``entry`` being received by
    the central.

    :param entry:
    rw   z(BluetoothEmulation.simulateAdvertisementrg   Nrj   )rw   ri   rk   r   r   r   r   simulate_advertisement@  s   	
rx   type_coder7   c                 c  s8    t  }| |d< | |d< ||d< d|d}|V }dS )a#  
    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.

    :param address:
    :param type_:
    :param code:
    rp   typerz   z0BluetoothEmulation.simulateGATTOperationResponserg   Nrj   )rp   ry   rz   ri   rk   r   r   r   r    simulate_gatt_operation_responseR  s   
r|   characteristic_idr:   r@   c                 c  H    t  }| |d< | |d< ||d< |dur||d< d|d}|V }dS )a  
    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.

    :param characteristic_id:
    :param type_:
    :param code:
    :param data: *(Optional)*
    characteristicIdr{   rz   Nr:   z:BluetoothEmulation.simulateCharacteristicOperationResponserg   rj   )r}   ry   rz   r:   ri   rk   r   r   r   r   *simulate_characteristic_operation_responsek     
r   descriptor_idc                 c  r~   )a  
    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.

    :param descriptor_id:
    :param type_:
    :param code:
    :param data: *(Optional)*
    descriptorIdr{   rz   Nr:   z6BluetoothEmulation.simulateDescriptorOperationResponserg   rj   )r   ry   rz   r:   ri   rk   r   r   r   r   &simulate_descriptor_operation_response  r   r   service_uuid/typing.Generator[T_JSON_DICT, T_JSON_DICT, str]c                 c  4    t  }| |d< ||d< d|d}|V }t|d S )z
    Adds a service with ``serviceUuid`` to the peripheral with ``address``.

    :param address:
    :param service_uuid:
    :returns: An identifier that uniquely represents this service.
    rp   serviceUuidzBluetoothEmulation.addServicerg   	serviceIdr;   r9   )rp   r   ri   rk   r   r   r   r   add_service  s   r   
service_idc                 c  $    t  }| |d< d|d}|V }dS )zo
    Removes the service respresented by ``serviceId`` from the simulated central.

    :param service_id:
    r   z BluetoothEmulation.removeServicerg   Nru   )r   ri   rk   r   r   r   r   remove_service     
r   characteristic_uuid
propertiesc                 c  s@    t  }| |d< ||d< | |d< d|d}|V }t|d S )a  
    Adds a characteristic with ``characteristicUuid`` and ``properties`` to the
    service represented by ``serviceId``.

    :param service_id:
    :param characteristic_uuid:
    :param properties:
    :returns: An identifier that uniquely represents this characteristic.
    r   characteristicUuidr   z$BluetoothEmulation.addCharacteristicrg   r   )r;   r   r9   )r   r   r   ri   rk   r   r   r   r   add_characteristic  s   r   c                 c  r   )z
    Removes the characteristic respresented by ``characteristicId`` from the
    simulated central.

    :param characteristic_id:
    r   z'BluetoothEmulation.removeCharacteristicrg   Nru   )r}   ri   rk   r   r   r   r   remove_characteristic  s   	
r   descriptor_uuidc                 c  r   )z
    Adds a descriptor with ``descriptorUuid`` to the characteristic respresented
    by ``characteristicId``.

    :param characteristic_id:
    :param descriptor_uuid:
    :returns: An identifier that uniquely represents this descriptor.
    r   descriptorUuidz BluetoothEmulation.addDescriptorrg   r   r   )r}   r   ri   rk   r   r   r   r   add_descriptor  s   r   c                 c  r   )zm
    Removes the descriptor with ``descriptorId`` from the simulated central.

    :param descriptor_id:
    r   z#BluetoothEmulation.removeDescriptorrg   Nru   )r   ri   rk   r   r   r   r   remove_descriptor  r   r   c                 c  r   )zc
    Simulates a GATT disconnection from the peripheral with ``address``.

    :param address:
    rp   z,BluetoothEmulation.simulateGATTDisconnectionrg   Nru   )rp   ri   rk   r   r   r   r   simulate_gatt_disconnection$  r   r   z(BluetoothEmulation.gattOperationReceivedc                   @  s0   e Zd ZU dZded< ded< edd	d
ZdS )GattOperationReceivedzf
    Event for when a GATT operation of ``type`` to the peripheral with ``address``
    happened.
    r9   rp   r$   ry   r   r   rd   c                 C  s   | t |d t|d dS )Nrp   r{   )rp   ry   )r9   r$   r   r   r   r   r   r   ?  s   
zGattOperationReceived.from_jsonN)r   r   rd   r   r   r   r   r   r>   r!   r   r   r   r   r   r   5  s   
 r   z2BluetoothEmulation.characteristicOperationReceivedc                   @  s@   e Zd ZU dZded< ded< ded< ded	< edddZdS )CharacteristicOperationReceivedz
    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.
    r9   r}   r.   ry   r@   r:   z(typing.Optional[CharacteristicWriteType]
write_typer   r   rd   c                 C  sP   | t |d t|d d|v rt |d nd d|v r$t|d dS d dS )Nr   r{   r:   	writeType)r}   ry   r:   r   )r9   r.   r   r*   r   r   r   r   r   T  s   
z)CharacteristicOperationReceived.from_jsonN)r   r   rd   r   r   r   r   r   r   r   G  s   
 r   z.BluetoothEmulation.descriptorOperationReceivedc                   @  s8   e Zd ZU dZded< ded< ded< edddZdS )DescriptorOperationReceivedz
    Event for when a descriptor operation of ``type`` to the descriptor
    respresented by ``descriptorId`` happened. ``data`` is expected to exist when
    ``type`` is write.
    r9   r   r5   ry   r@   r:   r   r   rd   c                 C  s8   | t |d t|d d|v rt |d dS d dS )Nr   r{   r:   )r   ry   r:   )r9   r5   r   r   r   r   r   r   j  s   
z%DescriptorOperationReceived.from_jsonN)r   r   rd   r   r   r   r   r   r   r   ^  s   
 r   )rb   r   rc   ra   rd   re   )rb   r   rd   re   )rd   re   )
rp   r9   rA   r9   rE   rq   rr   rs   rd   re   )rw   rQ   rd   re   )rp   r9   ry   r$   rz   r7   rd   re   r   )
r}   r9   ry   r.   rz   r7   r:   r@   rd   re   )
r   r9   ry   r5   rz   r7   r:   r@   rd   re   )rp   r9   r   r9   rd   r   )r   r9   rd   re   )r   r9   r   r9   r   rW   rd   r   )r}   r9   rd   re   )r}   r9   r   r9   rd   r   )r   r9   rd   re   )rp   r9   rd   re   )%
__future__r   utilr   r   dataclassesr   enumtypingEnumr   r$   r*   r.   r5   r6   r?   rQ   rW   rl   rn   ro   rv   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sX   +
7





#






