Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
56 lines (50 loc) · 1.96 KB
/
Copy path__init__.py
File metadata and controls
56 lines (50 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""A HAP client (controller) for driving a HAP accessory over the real protocol.
The client speaks the same protocol as a real iOS controller:
* ``POST /pair-verify`` with X25519/Ed25519/HKDF and TLV payloads, based on a
pre-paired long-term identity (:class:`ClientIdentity`).
* The encrypted transport (ChaCha20-Poly1305 in 1024 byte blocks) via
:class:`pyhap.hap_crypto.HAPCrypto` in ``client_side`` mode.
* Plain HTTP/1.1 requests for characteristic reads/writes, subscriptions and
``GET /accessories``, plus parsing of interleaved ``EVENT/1.0`` push frames
on the same connection.
It is used by the benchmark suite (``benchmarks/run.py``) and by the
integration tests in ``tests/integration/`` to exercise a running
:class:`pyhap.accessory_driver.AccessoryDriver` end to end::
# A controller whose identity is persisted at controller.key: loaded
# back on later runs, created and saved on the first. Pass
# accessory_ltpk=... or accessory_state="accessory.state" once to pin
# the accessory's key for verification (on another machine, point
# accessory_state at a copy of the accessory's state file).
client = HAPClient.new_persistent(filepath="controller.key")
driver.pair(
client.identity.uuid_bytes,
client.identity.public_key_bytes,
HAP_PERMISSIONS.ADMIN,
)
# ... start the driver, then:
await client.connect("127.0.0.1", port)
frame = await client.get_accessories()
"""
from ..const import RESPONSE_TIMEOUT
from .controller import HAPClient
from .identity import ClientIdentity
from .protocol import Frame, parse_frame
from .state import (
add_client_pairing,
load_accessory_ltpk,
load_accessory_state,
remove_client_pairing,
save_accessory_state,
)
__all__ = [
"RESPONSE_TIMEOUT",
"ClientIdentity",
"Frame",
"HAPClient",
"add_client_pairing",
"load_accessory_ltpk",
"load_accessory_state",
"parse_frame",
"remove_client_pairing",
"save_accessory_state",
]