From 2746005739129c350c21e4714c900782c504b270 Mon Sep 17 00:00:00 2001 From: Christopher Hoch <60989727+dumpfheimer@users.noreply.github.com> Date: Sat, 8 Oct 2022 04:06:31 +0200 Subject: [PATCH] pass down NETWORK_COMMISSIONING_TIMEOUT to request() (#183) Co-authored-by: Christopher Hoch --- zigpy_znp/api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zigpy_znp/api.py b/zigpy_znp/api.py index 6f95a310..b82a38f4 100644 --- a/zigpy_znp/api.py +++ b/zigpy_znp/api.py @@ -43,7 +43,7 @@ # All of these are in seconds STARTUP_TIMEOUT = 15 AFTER_BOOTLOADER_SKIP_BYTE_DELAY = 2.5 -NETWORK_COMMISSIONING_TIMEOUT = 30 +NETWORK_COMMISSIONING_TIMEOUT = 60 BOOTLOADER_PIN_TOGGLE_DELAY = 0.15 CONNECT_PING_TIMEOUT = 0.50 CONNECT_PROBE_TIMEOUT = 10 @@ -935,7 +935,7 @@ def wait_for_response(self, response: t.CommandBase) -> asyncio.Future: return self.wait_for_responses([response]) async def request( - self, request: t.CommandBase, **response_params + self, request: t.CommandBase, timeout: int | None = None, **response_params ) -> t.CommandBase | None: """ Sends a SREQ/AREQ request and returns its SRSP (only for SREQ), failing if any @@ -991,7 +991,9 @@ async def request( self._uart.send(frame) # We should get a SRSP in a reasonable amount of time - async with async_timeout.timeout(self._znp_config[conf.CONF_SREQ_TIMEOUT]): + async with async_timeout.timeout( + timeout or self._znp_config[conf.CONF_SREQ_TIMEOUT] + ): # We lock until either a sync response is seen or an error occurs response = await response_future @@ -1032,7 +1034,7 @@ async def request_callback_rsp( if not background: try: async with async_timeout.timeout(timeout): - await self.request(request, **response_params) + await self.request(request, timeout=timeout, **response_params) return await callback_rsp finally: