mithwire 0.50.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. mithwire/__init__.py +32 -0
  2. mithwire/cdp/README.md +4 -0
  3. mithwire/cdp/__init__.py +6 -0
  4. mithwire/cdp/accessibility.py +668 -0
  5. mithwire/cdp/animation.py +494 -0
  6. mithwire/cdp/audits.py +1995 -0
  7. mithwire/cdp/autofill.py +292 -0
  8. mithwire/cdp/background_service.py +215 -0
  9. mithwire/cdp/bluetooth_emulation.py +626 -0
  10. mithwire/cdp/browser.py +821 -0
  11. mithwire/cdp/cache_storage.py +311 -0
  12. mithwire/cdp/cast.py +172 -0
  13. mithwire/cdp/console.py +107 -0
  14. mithwire/cdp/crash_report_context.py +55 -0
  15. mithwire/cdp/css.py +2750 -0
  16. mithwire/cdp/database.py +179 -0
  17. mithwire/cdp/debugger.py +1405 -0
  18. mithwire/cdp/device_access.py +141 -0
  19. mithwire/cdp/device_orientation.py +45 -0
  20. mithwire/cdp/dom.py +2257 -0
  21. mithwire/cdp/dom_debugger.py +321 -0
  22. mithwire/cdp/dom_snapshot.py +876 -0
  23. mithwire/cdp/dom_storage.py +222 -0
  24. mithwire/cdp/emulation.py +1779 -0
  25. mithwire/cdp/event_breakpoints.py +56 -0
  26. mithwire/cdp/extensions.py +238 -0
  27. mithwire/cdp/fed_cm.py +283 -0
  28. mithwire/cdp/fetch.py +507 -0
  29. mithwire/cdp/file_system.py +115 -0
  30. mithwire/cdp/headless_experimental.py +115 -0
  31. mithwire/cdp/heap_profiler.py +401 -0
  32. mithwire/cdp/indexed_db.py +528 -0
  33. mithwire/cdp/input_.py +701 -0
  34. mithwire/cdp/inspector.py +95 -0
  35. mithwire/cdp/io.py +101 -0
  36. mithwire/cdp/layer_tree.py +464 -0
  37. mithwire/cdp/log.py +190 -0
  38. mithwire/cdp/media.py +313 -0
  39. mithwire/cdp/memory.py +305 -0
  40. mithwire/cdp/network.py +5342 -0
  41. mithwire/cdp/overlay.py +1468 -0
  42. mithwire/cdp/page.py +3972 -0
  43. mithwire/cdp/performance.py +124 -0
  44. mithwire/cdp/performance_timeline.py +200 -0
  45. mithwire/cdp/preload.py +575 -0
  46. mithwire/cdp/profiler.py +420 -0
  47. mithwire/cdp/pwa.py +278 -0
  48. mithwire/cdp/py.typed +0 -0
  49. mithwire/cdp/runtime.py +1589 -0
  50. mithwire/cdp/schema.py +50 -0
  51. mithwire/cdp/security.py +518 -0
  52. mithwire/cdp/service_worker.py +401 -0
  53. mithwire/cdp/smart_card_emulation.py +891 -0
  54. mithwire/cdp/storage.py +1573 -0
  55. mithwire/cdp/system_info.py +327 -0
  56. mithwire/cdp/target.py +829 -0
  57. mithwire/cdp/tethering.py +65 -0
  58. mithwire/cdp/tracing.py +377 -0
  59. mithwire/cdp/util.py +18 -0
  60. mithwire/cdp/web_audio.py +606 -0
  61. mithwire/cdp/web_authn.py +598 -0
  62. mithwire/cdp/web_mcp.py +293 -0
  63. mithwire/core/_contradict.py +142 -0
  64. mithwire/core/browser.py +923 -0
  65. mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
  66. mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
  67. mithwire/core/config.py +323 -0
  68. mithwire/core/connection.py +564 -0
  69. mithwire/core/element.py +1205 -0
  70. mithwire/core/tab.py +2202 -0
  71. mithwire/core/util.py +5063 -0
  72. mithwire-0.50.3.dist-info/METADATA +1049 -0
  73. mithwire-0.50.3.dist-info/RECORD +76 -0
  74. mithwire-0.50.3.dist-info/WHEEL +5 -0
  75. mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
  76. mithwire-0.50.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,626 @@
1
+ # DO NOT EDIT THIS FILE!
2
+ #
3
+ # This file is generated from the CDP specification. If you need to make
4
+ # changes, edit the generator and regenerate all of the modules.
5
+ #
6
+ # CDP domain: BluetoothEmulation (experimental)
7
+
8
+ from __future__ import annotations
9
+ import enum
10
+ import typing
11
+ from dataclasses import dataclass
12
+ from .util import event_class, T_JSON_DICT
13
+
14
+
15
+ class CentralState(enum.Enum):
16
+ '''
17
+ Indicates the various states of Central.
18
+ '''
19
+ ABSENT = "absent"
20
+ POWERED_OFF = "powered-off"
21
+ POWERED_ON = "powered-on"
22
+
23
+ def to_json(self) -> str:
24
+ return self.value
25
+
26
+ @classmethod
27
+ def from_json(cls, json: str) -> CentralState:
28
+ return cls(json)
29
+
30
+
31
+ class GATTOperationType(enum.Enum):
32
+ '''
33
+ Indicates the various types of GATT event.
34
+ '''
35
+ CONNECTION = "connection"
36
+ DISCOVERY = "discovery"
37
+
38
+ def to_json(self) -> str:
39
+ return self.value
40
+
41
+ @classmethod
42
+ def from_json(cls, json: str) -> GATTOperationType:
43
+ return cls(json)
44
+
45
+
46
+ class CharacteristicWriteType(enum.Enum):
47
+ '''
48
+ Indicates the various types of characteristic write.
49
+ '''
50
+ WRITE_DEFAULT_DEPRECATED = "write-default-deprecated"
51
+ WRITE_WITH_RESPONSE = "write-with-response"
52
+ WRITE_WITHOUT_RESPONSE = "write-without-response"
53
+
54
+ def to_json(self) -> str:
55
+ return self.value
56
+
57
+ @classmethod
58
+ def from_json(cls, json: str) -> CharacteristicWriteType:
59
+ return cls(json)
60
+
61
+
62
+ class CharacteristicOperationType(enum.Enum):
63
+ '''
64
+ Indicates the various types of characteristic operation.
65
+ '''
66
+ READ = "read"
67
+ WRITE = "write"
68
+ SUBSCRIBE_TO_NOTIFICATIONS = "subscribe-to-notifications"
69
+ UNSUBSCRIBE_FROM_NOTIFICATIONS = "unsubscribe-from-notifications"
70
+
71
+ def to_json(self) -> str:
72
+ return self.value
73
+
74
+ @classmethod
75
+ def from_json(cls, json: str) -> CharacteristicOperationType:
76
+ return cls(json)
77
+
78
+
79
+ class DescriptorOperationType(enum.Enum):
80
+ '''
81
+ Indicates the various types of descriptor operation.
82
+ '''
83
+ READ = "read"
84
+ WRITE = "write"
85
+
86
+ def to_json(self) -> str:
87
+ return self.value
88
+
89
+ @classmethod
90
+ def from_json(cls, json: str) -> DescriptorOperationType:
91
+ return cls(json)
92
+
93
+
94
+ @dataclass
95
+ class ManufacturerData:
96
+ '''
97
+ Stores the manufacturer data
98
+ '''
99
+ #: Company identifier
100
+ #: https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yaml
101
+ #: https://usb.org/developers
102
+ key: int
103
+
104
+ #: Manufacturer-specific data (Encoded as a base64 string when passed over JSON)
105
+ data: str
106
+
107
+ def to_json(self) -> T_JSON_DICT:
108
+ json: T_JSON_DICT = dict()
109
+ json['key'] = self.key
110
+ json['data'] = self.data
111
+ return json
112
+
113
+ @classmethod
114
+ def from_json(cls, json: T_JSON_DICT) -> ManufacturerData:
115
+ return cls(
116
+ key=int(json['key']),
117
+ data=str(json['data']),
118
+ )
119
+
120
+
121
+ @dataclass
122
+ class ScanRecord:
123
+ '''
124
+ Stores the byte data of the advertisement packet sent by a Bluetooth device.
125
+ '''
126
+ name: typing.Optional[str] = None
127
+
128
+ uuids: typing.Optional[typing.List[str]] = None
129
+
130
+ #: Stores the external appearance description of the device.
131
+ appearance: typing.Optional[int] = None
132
+
133
+ #: Stores the transmission power of a broadcasting device.
134
+ tx_power: typing.Optional[int] = None
135
+
136
+ #: Key is the company identifier and the value is an array of bytes of
137
+ #: manufacturer specific data.
138
+ manufacturer_data: typing.Optional[typing.List[ManufacturerData]] = None
139
+
140
+ def to_json(self) -> T_JSON_DICT:
141
+ json: T_JSON_DICT = dict()
142
+ if self.name is not None:
143
+ json['name'] = self.name
144
+ if self.uuids is not None:
145
+ json['uuids'] = [i for i in self.uuids]
146
+ if self.appearance is not None:
147
+ json['appearance'] = self.appearance
148
+ if self.tx_power is not None:
149
+ json['txPower'] = self.tx_power
150
+ if self.manufacturer_data is not None:
151
+ json['manufacturerData'] = [i.to_json() for i in self.manufacturer_data]
152
+ return json
153
+
154
+ @classmethod
155
+ def from_json(cls, json: T_JSON_DICT) -> ScanRecord:
156
+ return cls(
157
+ name=str(json['name']) if json.get('name', None) is not None else None,
158
+ uuids=[str(i) for i in json['uuids']] if json.get('uuids', None) is not None else None,
159
+ appearance=int(json['appearance']) if json.get('appearance', None) is not None else None,
160
+ tx_power=int(json['txPower']) if json.get('txPower', None) is not None else None,
161
+ manufacturer_data=[ManufacturerData.from_json(i) for i in json['manufacturerData']] if json.get('manufacturerData', None) is not None else None,
162
+ )
163
+
164
+
165
+ @dataclass
166
+ class ScanEntry:
167
+ '''
168
+ Stores the advertisement packet information that is sent by a Bluetooth device.
169
+ '''
170
+ device_address: str
171
+
172
+ rssi: int
173
+
174
+ scan_record: ScanRecord
175
+
176
+ def to_json(self) -> T_JSON_DICT:
177
+ json: T_JSON_DICT = dict()
178
+ json['deviceAddress'] = self.device_address
179
+ json['rssi'] = self.rssi
180
+ json['scanRecord'] = self.scan_record.to_json()
181
+ return json
182
+
183
+ @classmethod
184
+ def from_json(cls, json: T_JSON_DICT) -> ScanEntry:
185
+ return cls(
186
+ device_address=str(json['deviceAddress']),
187
+ rssi=int(json['rssi']),
188
+ scan_record=ScanRecord.from_json(json['scanRecord']),
189
+ )
190
+
191
+
192
+ @dataclass
193
+ class CharacteristicProperties:
194
+ '''
195
+ Describes the properties of a characteristic. This follows Bluetooth Core
196
+ Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.
197
+ '''
198
+ broadcast: typing.Optional[bool] = None
199
+
200
+ read: typing.Optional[bool] = None
201
+
202
+ write_without_response: typing.Optional[bool] = None
203
+
204
+ write: typing.Optional[bool] = None
205
+
206
+ notify: typing.Optional[bool] = None
207
+
208
+ indicate: typing.Optional[bool] = None
209
+
210
+ authenticated_signed_writes: typing.Optional[bool] = None
211
+
212
+ extended_properties: typing.Optional[bool] = None
213
+
214
+ def to_json(self) -> T_JSON_DICT:
215
+ json: T_JSON_DICT = dict()
216
+ if self.broadcast is not None:
217
+ json['broadcast'] = self.broadcast
218
+ if self.read is not None:
219
+ json['read'] = self.read
220
+ if self.write_without_response is not None:
221
+ json['writeWithoutResponse'] = self.write_without_response
222
+ if self.write is not None:
223
+ json['write'] = self.write
224
+ if self.notify is not None:
225
+ json['notify'] = self.notify
226
+ if self.indicate is not None:
227
+ json['indicate'] = self.indicate
228
+ if self.authenticated_signed_writes is not None:
229
+ json['authenticatedSignedWrites'] = self.authenticated_signed_writes
230
+ if self.extended_properties is not None:
231
+ json['extendedProperties'] = self.extended_properties
232
+ return json
233
+
234
+ @classmethod
235
+ def from_json(cls, json: T_JSON_DICT) -> CharacteristicProperties:
236
+ return cls(
237
+ broadcast=bool(json['broadcast']) if json.get('broadcast', None) is not None else None,
238
+ read=bool(json['read']) if json.get('read', None) is not None else None,
239
+ write_without_response=bool(json['writeWithoutResponse']) if json.get('writeWithoutResponse', None) is not None else None,
240
+ write=bool(json['write']) if json.get('write', None) is not None else None,
241
+ notify=bool(json['notify']) if json.get('notify', None) is not None else None,
242
+ indicate=bool(json['indicate']) if json.get('indicate', None) is not None else None,
243
+ authenticated_signed_writes=bool(json['authenticatedSignedWrites']) if json.get('authenticatedSignedWrites', None) is not None else None,
244
+ extended_properties=bool(json['extendedProperties']) if json.get('extendedProperties', None) is not None else None,
245
+ )
246
+
247
+
248
+ def enable(
249
+ state: CentralState,
250
+ le_supported: bool
251
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
252
+ '''
253
+ Enable the BluetoothEmulation domain.
254
+
255
+ :param state: State of the simulated central.
256
+ :param le_supported: If the simulated central supports low-energy.
257
+ '''
258
+ params: T_JSON_DICT = dict()
259
+ params['state'] = state.to_json()
260
+ params['leSupported'] = le_supported
261
+ cmd_dict: T_JSON_DICT = {
262
+ 'method': 'BluetoothEmulation.enable',
263
+ 'params': params,
264
+ }
265
+ json = yield cmd_dict
266
+
267
+
268
+ def set_simulated_central_state(
269
+ state: CentralState
270
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
271
+ '''
272
+ Set the state of the simulated central.
273
+
274
+ :param state: State of the simulated central.
275
+ '''
276
+ params: T_JSON_DICT = dict()
277
+ params['state'] = state.to_json()
278
+ cmd_dict: T_JSON_DICT = {
279
+ 'method': 'BluetoothEmulation.setSimulatedCentralState',
280
+ 'params': params,
281
+ }
282
+ json = yield cmd_dict
283
+
284
+
285
+ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
286
+ '''
287
+ Disable the BluetoothEmulation domain.
288
+ '''
289
+ cmd_dict: T_JSON_DICT = {
290
+ 'method': 'BluetoothEmulation.disable',
291
+ }
292
+ json = yield cmd_dict
293
+
294
+
295
+ def simulate_preconnected_peripheral(
296
+ address: str,
297
+ name: str,
298
+ manufacturer_data: typing.List[ManufacturerData],
299
+ known_service_uuids: typing.List[str]
300
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
301
+ '''
302
+ Simulates a peripheral with ``address``, ``name`` and ``knownServiceUuids``
303
+ that has already been connected to the system.
304
+
305
+ :param address:
306
+ :param name:
307
+ :param manufacturer_data:
308
+ :param known_service_uuids:
309
+ '''
310
+ params: T_JSON_DICT = dict()
311
+ params['address'] = address
312
+ params['name'] = name
313
+ params['manufacturerData'] = [i.to_json() for i in manufacturer_data]
314
+ params['knownServiceUuids'] = [i for i in known_service_uuids]
315
+ cmd_dict: T_JSON_DICT = {
316
+ 'method': 'BluetoothEmulation.simulatePreconnectedPeripheral',
317
+ 'params': params,
318
+ }
319
+ json = yield cmd_dict
320
+
321
+
322
+ def simulate_advertisement(
323
+ entry: ScanEntry
324
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
325
+ '''
326
+ Simulates an advertisement packet described in ``entry`` being received by
327
+ the central.
328
+
329
+ :param entry:
330
+ '''
331
+ params: T_JSON_DICT = dict()
332
+ params['entry'] = entry.to_json()
333
+ cmd_dict: T_JSON_DICT = {
334
+ 'method': 'BluetoothEmulation.simulateAdvertisement',
335
+ 'params': params,
336
+ }
337
+ json = yield cmd_dict
338
+
339
+
340
+ def simulate_gatt_operation_response(
341
+ address: str,
342
+ type_: GATTOperationType,
343
+ code: int
344
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
345
+ '''
346
+ Simulates the response code from the peripheral with ``address`` for a
347
+ GATT operation of ``type``. The ``code`` value follows the HCI Error Codes from
348
+ Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes.
349
+
350
+ :param address:
351
+ :param type_:
352
+ :param code:
353
+ '''
354
+ params: T_JSON_DICT = dict()
355
+ params['address'] = address
356
+ params['type'] = type_.to_json()
357
+ params['code'] = code
358
+ cmd_dict: T_JSON_DICT = {
359
+ 'method': 'BluetoothEmulation.simulateGATTOperationResponse',
360
+ 'params': params,
361
+ }
362
+ json = yield cmd_dict
363
+
364
+
365
+ def simulate_characteristic_operation_response(
366
+ characteristic_id: str,
367
+ type_: CharacteristicOperationType,
368
+ code: int,
369
+ data: typing.Optional[str] = None
370
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
371
+ '''
372
+ Simulates the response from the characteristic with ``characteristicId`` for a
373
+ characteristic operation of ``type``. The ``code`` value follows the Error
374
+ Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
375
+ The ``data`` is expected to exist when simulating a successful read operation
376
+ response.
377
+
378
+ :param characteristic_id:
379
+ :param type_:
380
+ :param code:
381
+ :param data: *(Optional)*
382
+ '''
383
+ params: T_JSON_DICT = dict()
384
+ params['characteristicId'] = characteristic_id
385
+ params['type'] = type_.to_json()
386
+ params['code'] = code
387
+ if data is not None:
388
+ params['data'] = data
389
+ cmd_dict: T_JSON_DICT = {
390
+ 'method': 'BluetoothEmulation.simulateCharacteristicOperationResponse',
391
+ 'params': params,
392
+ }
393
+ json = yield cmd_dict
394
+
395
+
396
+ def simulate_descriptor_operation_response(
397
+ descriptor_id: str,
398
+ type_: DescriptorOperationType,
399
+ code: int,
400
+ data: typing.Optional[str] = None
401
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
402
+ '''
403
+ Simulates the response from the descriptor with ``descriptorId`` for a
404
+ descriptor operation of ``type``. The ``code`` value follows the Error
405
+ Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
406
+ The ``data`` is expected to exist when simulating a successful read operation
407
+ response.
408
+
409
+ :param descriptor_id:
410
+ :param type_:
411
+ :param code:
412
+ :param data: *(Optional)*
413
+ '''
414
+ params: T_JSON_DICT = dict()
415
+ params['descriptorId'] = descriptor_id
416
+ params['type'] = type_.to_json()
417
+ params['code'] = code
418
+ if data is not None:
419
+ params['data'] = data
420
+ cmd_dict: T_JSON_DICT = {
421
+ 'method': 'BluetoothEmulation.simulateDescriptorOperationResponse',
422
+ 'params': params,
423
+ }
424
+ json = yield cmd_dict
425
+
426
+
427
+ def add_service(
428
+ address: str,
429
+ service_uuid: str
430
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
431
+ '''
432
+ Adds a service with ``serviceUuid`` to the peripheral with ``address``.
433
+
434
+ :param address:
435
+ :param service_uuid:
436
+ :returns: An identifier that uniquely represents this service.
437
+ '''
438
+ params: T_JSON_DICT = dict()
439
+ params['address'] = address
440
+ params['serviceUuid'] = service_uuid
441
+ cmd_dict: T_JSON_DICT = {
442
+ 'method': 'BluetoothEmulation.addService',
443
+ 'params': params,
444
+ }
445
+ json = yield cmd_dict
446
+ return str(json['serviceId'])
447
+
448
+
449
+ def remove_service(
450
+ service_id: str
451
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
452
+ '''
453
+ Removes the service respresented by ``serviceId`` from the simulated central.
454
+
455
+ :param service_id:
456
+ '''
457
+ params: T_JSON_DICT = dict()
458
+ params['serviceId'] = service_id
459
+ cmd_dict: T_JSON_DICT = {
460
+ 'method': 'BluetoothEmulation.removeService',
461
+ 'params': params,
462
+ }
463
+ json = yield cmd_dict
464
+
465
+
466
+ def add_characteristic(
467
+ service_id: str,
468
+ characteristic_uuid: str,
469
+ properties: CharacteristicProperties
470
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
471
+ '''
472
+ Adds a characteristic with ``characteristicUuid`` and ``properties`` to the
473
+ service represented by ``serviceId``.
474
+
475
+ :param service_id:
476
+ :param characteristic_uuid:
477
+ :param properties:
478
+ :returns: An identifier that uniquely represents this characteristic.
479
+ '''
480
+ params: T_JSON_DICT = dict()
481
+ params['serviceId'] = service_id
482
+ params['characteristicUuid'] = characteristic_uuid
483
+ params['properties'] = properties.to_json()
484
+ cmd_dict: T_JSON_DICT = {
485
+ 'method': 'BluetoothEmulation.addCharacteristic',
486
+ 'params': params,
487
+ }
488
+ json = yield cmd_dict
489
+ return str(json['characteristicId'])
490
+
491
+
492
+ def remove_characteristic(
493
+ characteristic_id: str
494
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
495
+ '''
496
+ Removes the characteristic respresented by ``characteristicId`` from the
497
+ simulated central.
498
+
499
+ :param characteristic_id:
500
+ '''
501
+ params: T_JSON_DICT = dict()
502
+ params['characteristicId'] = characteristic_id
503
+ cmd_dict: T_JSON_DICT = {
504
+ 'method': 'BluetoothEmulation.removeCharacteristic',
505
+ 'params': params,
506
+ }
507
+ json = yield cmd_dict
508
+
509
+
510
+ def add_descriptor(
511
+ characteristic_id: str,
512
+ descriptor_uuid: str
513
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
514
+ '''
515
+ Adds a descriptor with ``descriptorUuid`` to the characteristic respresented
516
+ by ``characteristicId``.
517
+
518
+ :param characteristic_id:
519
+ :param descriptor_uuid:
520
+ :returns: An identifier that uniquely represents this descriptor.
521
+ '''
522
+ params: T_JSON_DICT = dict()
523
+ params['characteristicId'] = characteristic_id
524
+ params['descriptorUuid'] = descriptor_uuid
525
+ cmd_dict: T_JSON_DICT = {
526
+ 'method': 'BluetoothEmulation.addDescriptor',
527
+ 'params': params,
528
+ }
529
+ json = yield cmd_dict
530
+ return str(json['descriptorId'])
531
+
532
+
533
+ def remove_descriptor(
534
+ descriptor_id: str
535
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
536
+ '''
537
+ Removes the descriptor with ``descriptorId`` from the simulated central.
538
+
539
+ :param descriptor_id:
540
+ '''
541
+ params: T_JSON_DICT = dict()
542
+ params['descriptorId'] = descriptor_id
543
+ cmd_dict: T_JSON_DICT = {
544
+ 'method': 'BluetoothEmulation.removeDescriptor',
545
+ 'params': params,
546
+ }
547
+ json = yield cmd_dict
548
+
549
+
550
+ def simulate_gatt_disconnection(
551
+ address: str
552
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
553
+ '''
554
+ Simulates a GATT disconnection from the peripheral with ``address``.
555
+
556
+ :param address:
557
+ '''
558
+ params: T_JSON_DICT = dict()
559
+ params['address'] = address
560
+ cmd_dict: T_JSON_DICT = {
561
+ 'method': 'BluetoothEmulation.simulateGATTDisconnection',
562
+ 'params': params,
563
+ }
564
+ json = yield cmd_dict
565
+
566
+
567
+ @event_class('BluetoothEmulation.gattOperationReceived')
568
+ @dataclass
569
+ class GattOperationReceived:
570
+ '''
571
+ Event for when a GATT operation of ``type`` to the peripheral with ``address``
572
+ happened.
573
+ '''
574
+ address: str
575
+ type_: GATTOperationType
576
+
577
+ @classmethod
578
+ def from_json(cls, json: T_JSON_DICT) -> GattOperationReceived:
579
+ return cls(
580
+ address=str(json['address']),
581
+ type_=GATTOperationType.from_json(json['type'])
582
+ )
583
+
584
+
585
+ @event_class('BluetoothEmulation.characteristicOperationReceived')
586
+ @dataclass
587
+ class CharacteristicOperationReceived:
588
+ '''
589
+ Event for when a characteristic operation of ``type`` to the characteristic
590
+ respresented by ``characteristicId`` happened. ``data`` and ``writeType`` is
591
+ expected to exist when ``type`` is write.
592
+ '''
593
+ characteristic_id: str
594
+ type_: CharacteristicOperationType
595
+ data: typing.Optional[str]
596
+ write_type: typing.Optional[CharacteristicWriteType]
597
+
598
+ @classmethod
599
+ def from_json(cls, json: T_JSON_DICT) -> CharacteristicOperationReceived:
600
+ return cls(
601
+ characteristic_id=str(json['characteristicId']),
602
+ type_=CharacteristicOperationType.from_json(json['type']),
603
+ data=str(json['data']) if json.get('data', None) is not None else None,
604
+ write_type=CharacteristicWriteType.from_json(json['writeType']) if json.get('writeType', None) is not None else None
605
+ )
606
+
607
+
608
+ @event_class('BluetoothEmulation.descriptorOperationReceived')
609
+ @dataclass
610
+ class DescriptorOperationReceived:
611
+ '''
612
+ Event for when a descriptor operation of ``type`` to the descriptor
613
+ respresented by ``descriptorId`` happened. ``data`` is expected to exist when
614
+ ``type`` is write.
615
+ '''
616
+ descriptor_id: str
617
+ type_: DescriptorOperationType
618
+ data: typing.Optional[str]
619
+
620
+ @classmethod
621
+ def from_json(cls, json: T_JSON_DICT) -> DescriptorOperationReceived:
622
+ return cls(
623
+ descriptor_id=str(json['descriptorId']),
624
+ type_=DescriptorOperationType.from_json(json['type']),
625
+ data=str(json['data']) if json.get('data', None) is not None else None
626
+ )