Skip to content

Commit

Permalink
send multiple handshake requests just in case, reuses retry_count to …
Browse files Browse the repository at this point in the history
…decide on the number
  • Loading branch information
rytilahti committed Apr 28, 2020
1 parent 85e119c commit 248d033
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions miio/miioprotocol.py
Expand Up @@ -102,7 +102,8 @@ def discover(addr: str = None) -> Any:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.settimeout(timeout)
s.sendto(helobytes, (addr, 54321))
for _ in range(3):
s.sendto(helobytes, (addr, 54321))
while True:
try:
data, addr = s.recvfrom(1024)
Expand Down Expand Up @@ -141,7 +142,7 @@ def send(
:param str command: Command to send
:param dict parameters: Parameters to send, or an empty list
:param retry_count: How many times to retry in case of failure
:param retry_count: How many times to retry in case of failure, how many handshakes to send
:param dict extra_parameters: Extra top-level parameters
:raises DeviceException: if an error has occurred during communication."""

Expand Down

0 comments on commit 248d033

Please sign in to comment.