Skip to content

Commit

Permalink
pass down NETWORK_COMMISSIONING_TIMEOUT to request() (#183)
Browse files Browse the repository at this point in the history
Co-authored-by: Christopher Hoch <[email protected]>
  • Loading branch information
dumpfheimer and Christopher Hoch authored Oct 8, 2022
1 parent 1e9f237 commit 2746005
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2746005

Please sign in to comment.