Skip to content

Commit

Permalink
chore: reconnect refresh_status
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed Sep 25, 2024
1 parent 19a2873 commit 5c23ea3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions midealocal/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def connect(self, init: bool = False) -> bool:
_LOGGER.debug("[%s] Connected", self._device_id)
if self._protocol == ProtocolVersion.V3:
self.authenticate()
# init connect, check_protocol
# reconnect skip check_protocol
self.refresh_status(check_protocol=init)
if init:
self.refresh_status(check_protocol=True)
self.get_capabilities()
connected = True
except TimeoutError:
Expand Down Expand Up @@ -290,10 +290,19 @@ def send_message_v2(self, data: bytes, query: bool = False) -> None:
# raise exception to main loop
raise SocketException
try:
_LOGGER.debug(
"[%s] send_message_v2 with data %s",
self._device_id,
data.hex(),
)
# query msg, set timeout to QUERY_TIMEOUT
if query:
self._socket.settimeout(QUERY_TIMEOUT)
self._socket.send(data)
_LOGGER.debug(
"[%s] send_message_v2 success",
self._device_id,
)
except TimeoutError:
_LOGGER.debug(
"[%s] send_message_v2 timed out",
Expand Down

0 comments on commit 5c23ea3

Please sign in to comment.