Skip to content

Commit a683baf

Browse files
committed
Keep pinging as long as the ping task is running
1 parent 64f4c59 commit a683baf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

zigpy_znp/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,18 @@ async def ping_task():
488488
# If that doesn't work, send the bootloader skip bytes and try again.
489489
# Sending a bunch at a time fixes UART issues when the radio was previously
490490
# probed with another library at a different baudrate.
491+
LOGGER.debug("Sending CC253x bootloader skip bytes")
491492
self._uart.write(256 * bytes([c.ubl.BootloaderRunMode.FORCE_RUN]))
492493

493494
await asyncio.sleep(AFTER_BOOTLOADER_SKIP_BYTE_DELAY)
494495

495-
try:
496-
async with async_timeout.timeout(CONNECT_PING_TIMEOUT):
497-
return await self.request(c.SYS.Ping.Req())
498-
except asyncio.TimeoutError:
499-
pass
500-
501-
# At this point we have nothing else to try, don't catch the timeout
502-
return await self.request(c.SYS.Ping.Req())
496+
# At this point we have nothing left to try
497+
while True:
498+
try:
499+
async with async_timeout.timeout(2 * CONNECT_PING_TIMEOUT):
500+
return await self.request(c.SYS.Ping.Req())
501+
except asyncio.TimeoutError:
502+
pass
503503

504504
async with self.capture_responses([CatchAllResponse()]) as responses:
505505
ping_task = asyncio.create_task(ping_task())

0 commit comments

Comments
 (0)