diff --git a/pykirdy/driver/kirdy_async.py b/pykirdy/driver/kirdy_async.py index 4065f98..d63e6ff 100644 --- a/pykirdy/driver/kirdy_async.py +++ b/pykirdy/driver/kirdy_async.py @@ -93,15 +93,18 @@ class Device: self._read_response = read_response self._cmd_lock = cmd_lock - async def set_ip_settings(self, addr=[192, 168, 1, 128], port=1337, prefix_len=24, gateway=[192, 168, 1, 1]): + async def set_ip_settings(self, addr="192.168.1.128", port=1337, prefix_len=24, gateway="192.168.1.1"): """ After calling this fn, the ip settings are immediately saved into flash and will be effective on next reboot. """ - if not(isinstance(addr, list) and isinstance(gateway, list)): - raise InvalidDataType - - if not(len(addr) == 4 and len(gateway) == 4): + try: + socket.inet_aton(addr) + socket.inet_aton(gateway) + except OSError: raise InvalidDataType + + addr = addr.split(".") + gateway = gateway.split(".") if not(isinstance(port, int) and isinstance(prefix_len, int)): raise InvalidDataType