driver: Fix IP Settings not being able to update

This commit is contained in:
linuswck 2024-06-13 16:25:52 +08:00
parent 83a764889c
commit 3813b79623
1 changed files with 6 additions and 2 deletions

View File

@ -117,10 +117,10 @@ class Device:
{
"device_cmd": "SetIPSettings",
"ip_settings": {
"addr": addr,
"addr": [int(x) for x in addr],
"port": port,
"prefix_len": prefix_len,
"gateway": gateway,
"gateway": [int(x) for x in gateway],
}
}
)
@ -659,6 +659,8 @@ class Kirdy:
raw_response = await asyncio.wait_for(self._reader.read(buffer_size), self.timeout)
response = raw_response.decode('utf-8', errors='ignore').split("\n")
print()
print(response)
for item in reversed(response):
try:
return json.loads(item)
@ -732,9 +734,11 @@ class Kirdy:
self._writer.write(bytes(json.dumps(cmd_dict), "UTF-8"))
await self._writer.drain()
response = await self._read_response()
print(f'retry attempts: {retry} msg_type: {msg_type}')
if response["msg_type"] == msg_type:
return response
retry += 1
await asyncio.sleep(0.1)
except asyncio.exceptions.CancelledError:
return None