From 6d4b1b057453d505e85d003c297d89de804df513 Mon Sep 17 00:00:00 2001 From: linuswck Date: Wed, 4 Sep 2024 15:28:58 +0800 Subject: [PATCH] driver: end_session if ConnClose & Dfu is recv-ed --- pykirdy/driver/kirdy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pykirdy/driver/kirdy.py b/pykirdy/driver/kirdy.py index 90f6030..7767dd3 100644 --- a/pykirdy/driver/kirdy.py +++ b/pykirdy/driver/kirdy.py @@ -811,7 +811,14 @@ class Kirdy: response = await self._read_response() if response["msg_type"] == 'HardReset': + logging.warn("Kirdy is being hard reset.") raise asyncio.exceptions.CancelledError + if response["msg_type"] == 'Dfu': + logging.warn("Kirdy enters Dfu Mode.") + asyncio.create_task(self.end_session()) + if response["msg_type"] == 'ConnectionClose': + logging.warn("Kirdy runs out of TCP sockets and closes this connected socket.") + asyncio.create_task(self.end_session()) if response["msg_type"] == 'Report' and not self._msg_queue_get_report: if self._report_sig is None: self._report_queue.put_nowait_overwrite(response)