
    g                       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ej                        Z
e G d d	             Ze G d
 d             Ze G d d             Z	 	 	 	 ddZddZ	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZy)    )annotations   )event_classT_JSON_DICT)	dataclassNc                  2    e Zd ZdZdZdZdZd Zed        Z	y)CentralStatez2
    Indicates the various states of Central.
    absentzpowered-offz
powered-onc                    | j                   S N)value)selfs    n/var/www/html/venv/lib/python3.12/site-packages/selenium/webdriver/common/devtools/v129/bluetooth_emulation.pyto_jsonzCentralState.to_json   s    zz    c                     | |      S r    clsjsons     r   	from_jsonzCentralState.from_json   s    4yr   N)
__name__
__module____qualname____doc__ABSENTPOWERED_OFF
POWERED_ONr   classmethodr   r   r   r   r	   r	      s1     FKJ  r   r	   c                  <    e Zd ZU dZded<   ded<   d Zed        Zy)	ManufacturerDataz&
    Stores the manufacturer data
    intkeystrdatac                V    t               }| j                  |d<   | j                  |d<   |S )Nr#   r%   )dictr#   r%   r   r   s     r   r   zManufacturerData.to_json*   s(    vhhUyyVr   c                F     | t        |d         t        |d               S )Nr#   r%   )r#   r%   )r"   r$   r   s     r   r   zManufacturerData.from_json0   s'    DK T&\"
 	
r   Nr   r   r   r   __annotations__r   r   r   r   r   r   r!   r!      s.     
H I 
 
r   r!   c                  n    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
ed        Zy)
ScanRecordzV
    Stores the byte data of the advertisement packet sent by a Bluetooth device.
    Nztyping.Optional[str]namez!typing.Optional[typing.List[str]]uuidsztyping.Optional[int]
appearancetx_powerz.typing.Optional[typing.List[ManufacturerData]]manufacturer_datac                   t               }| j                  | j                  |d<   | j                  | j                  D cg c]  }| c}|d<   | j                  | j                  |d<   | j                  | j                  |d<   | j
                  +| j
                  D cg c]  }|j                          c}|d<   |S c c}w c c}w )Nr.   r/   r0   txPowermanufacturerData)r'   r.   r/   r0   r1   r2   r   )r   r   is      r   r   zScanRecord.to_jsonK   s    v99 99DL::!(,

31Q3DM??&!%D==$"mmDO!!-=A=S=S'T		'TD#$ 4 (Us    	B>Cc                :    | d|v rt        |d         nd d|v r|d   D cg c]  }t        |       c}nd d|v rt        |d         nd d|v rt        |d         nd d|v r+|d   D cg c]  }t        j                  |       c}      S d       S c c}w c c}w )Nr.   r/   r0   r4   r5   )r.   r/   r0   r1   r2   )r$   r"   r!   r   )r   r   r6   s      r   r   zScanRecord.from_jsonY   s    &,nT&\"$5<_4=1a3q61$2>$2Fs4-.D-6$->Si)Dcuy}c}dK]F^_/99!<_
 	

 DH
 	
1 `s   B
(B)r   r   r   r   r.   r+   r/   r0   r1   r2   r   r   r   r   r   r   r-   r-   8   sb     "&D
%/3E,3 (,J$+ &*H") IMEL 
 
r   r-   c                  F    e Zd ZU dZded<   ded<   ded<   d Zed	        Zy
)	ScanEntryzY
    Stores the advertisement packet information that is sent by a Bluetooth device.
    r$   device_addressr"   rssir-   scan_recordc                    t               }| j                  |d<   | j                  |d<   | j                  j	                         |d<   |S )NdeviceAddressr;   
scanRecord)r'   r:   r;   r<   r   r(   s     r   r   zScanEntry.to_jsono   sD    v $ 3 3_yyV!--557\r   c                t     | t        |d         t        |d         t        j                  |d               S )Nr>   r;   r?   )r:   r;   r<   )r$   r"   r-   r   r   s     r   r   zScanEntry.from_jsonv   s;    tO45T&\"",,T,-?@
 	
r   Nr*   r   r   r   r9   r9   d   s3     
I 
 
r   r9   c              #  X   K   t               }| j                         |d<   d|d}|}yw)zb
    Enable the BluetoothEmulation domain.

    :param state: State of the simulated central.
    statezBluetoothEmulation.enablemethodparamsNr'   r   )rB   rE   cmd_dictr   s       r   enablerH      s4      &FmmoF7O-H >D   (*c               #     K   ddi} | }yw)z0
    Disable the BluetoothEmulation domain.
    rD   zBluetoothEmulation.disableNr   )rG   r   s     r   disablerK      s     
 	.H >Ds   
c              #     K   t               }| |d<   ||d<   |D cg c]  }|j                          c}|d<   |D cg c]  }| c}|d<   d|d}|}yc c}w c c}w w)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:
    addressr.   r5   knownServiceUuidsz1BluetoothEmulation.simulatePreconnectedPeripheralrC   NrF   )rM   r.   r2   known_service_uuidsrE   r6   rG   r   s           r    simulate_preconnected_peripheralrP      ss      &FF9F6N7H!I!!))+!IF.A"B1"BFEH >D "J"Bs   AA
A	AAc              #  X   K   t               }| j                         |d<   d|d}|}yw)zx
    Simulates an advertisement packet described in ``entry`` being received by
    the central.

    :param entry:
    entryz(BluetoothEmulation.simulateAdvertisementrC   NrF   )rR   rE   rG   r   s       r   simulate_advertisementrS      s4      &FmmoF7O<H >DrI   )rB   r	   return0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])rT   rU   )
rM   r$   r.   r$   r2   ztyping.List[ManufacturerData]rO   ztyping.List[str]rT   rU   )rR   r9   rT   rU   )
__future__r   utilr   r   dataclassesr   enumtypingEnumr	   r!   r-   r9   rH   rK   rP   rS   r   r   r   <module>r\      s    # * !  499   
 
 
4 (
 (
 (
V 
 
 
4	7" 9 .	
 
86	7r   