1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-21 22:51:41 +01:00

Standardize ip_address option (#630)

This commit is contained in:
Felipe Martins Diel 2021-10-18 14:19:41 -03:00 committed by GitHub
parent 11febb043b
commit 9873af9bc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -192,7 +192,7 @@ def gendevice(
def hello(
host: str,
ip_address: str,
port: int = DEFAULT_PORT,
timeout: int = DEFAULT_TIMEOUT,
) -> Device:
@ -202,7 +202,11 @@ def hello(
"""
try:
return next(
xdiscover(timeout=timeout, discover_ip_address=host, discover_ip_port=port)
xdiscover(
timeout=timeout,
discover_ip_address=ip_address,
discover_ip_port=port,
)
)
except StopIteration as err:
raise e.NetworkTimeoutError(

View File

@ -76,7 +76,7 @@ def scan(
conn.close()
def ping(address: str, port: int = DEFAULT_PORT) -> None:
def ping(ip_address: str, port: int = DEFAULT_PORT) -> None:
"""Send a ping packet to an address.
This packet feeds the watchdog timer of firmwares >= v53.
@ -87,7 +87,7 @@ def ping(address: str, port: int = DEFAULT_PORT) -> None:
conn.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
packet = bytearray(0x30)
packet[0x26] = 1
conn.sendto(packet, (address, port))
conn.sendto(packet, (ip_address, port))
class Device: