mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-02-14 01:21:22 +01:00
Cleanup protobuf object construction (#715)
This commit is contained in:
parent
1360dd136a
commit
4230871761
@ -797,11 +797,9 @@ class APIClient:
|
||||
response: bool,
|
||||
timeout: float = DEFAULT_BLE_TIMEOUT,
|
||||
) -> None:
|
||||
req = BluetoothGATTWriteRequest()
|
||||
req.address = address
|
||||
req.handle = handle
|
||||
req.response = response
|
||||
req.data = data
|
||||
req = BluetoothGATTWriteRequest(
|
||||
address=address, handle=handle, response=response, data=data
|
||||
)
|
||||
|
||||
if not response:
|
||||
self._get_connection().send_message(req)
|
||||
@ -858,10 +856,9 @@ class APIClient:
|
||||
timeout: float = DEFAULT_BLE_TIMEOUT,
|
||||
wait_for_response: bool = True,
|
||||
) -> None:
|
||||
req = BluetoothGATTWriteDescriptorRequest()
|
||||
req.address = address
|
||||
req.handle = handle
|
||||
req.data = data
|
||||
req = BluetoothGATTWriteDescriptorRequest(
|
||||
address=address, handle=handle, data=data
|
||||
)
|
||||
|
||||
if not wait_for_response:
|
||||
self._get_connection().send_message(req)
|
||||
|
@ -361,17 +361,15 @@ class APIConnection:
|
||||
raise HandshakeAPIError(f"Handshake failed: {err}") from err
|
||||
self._set_connection_state(ConnectionState.HANDSHAKE_COMPLETE)
|
||||
|
||||
def _make_hello_request(self) -> HelloRequest:
|
||||
"""Make a HelloRequest."""
|
||||
hello = HelloRequest()
|
||||
hello.client_info = self._params.client_info
|
||||
hello.api_version_major = 1
|
||||
hello.api_version_minor = 9
|
||||
return hello
|
||||
|
||||
async def _connect_hello_login(self, login: bool) -> None:
|
||||
"""Step 4 in connect process: send hello and login and get api version."""
|
||||
messages = [self._make_hello_request()]
|
||||
messages = [
|
||||
HelloRequest(
|
||||
client_info=self._params.client_info,
|
||||
api_version_major=1,
|
||||
api_version_minor=9,
|
||||
)
|
||||
]
|
||||
msg_types = [HelloResponse]
|
||||
if login:
|
||||
messages.append(self._make_connect_request())
|
||||
|
Loading…
Reference in New Issue
Block a user