1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-22 07:00:12 +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( def hello(
host: str, ip_address: str,
port: int = DEFAULT_PORT, port: int = DEFAULT_PORT,
timeout: int = DEFAULT_TIMEOUT, timeout: int = DEFAULT_TIMEOUT,
) -> Device: ) -> Device:
@ -202,7 +202,11 @@ def hello(
""" """
try: try:
return next( 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: except StopIteration as err:
raise e.NetworkTimeoutError( raise e.NetworkTimeoutError(

View File

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