Skip to content

Commit f69c407

Browse files
committed
Speed up disconnect
1 parent f60d410 commit f69c407

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

zigpy_znp/api.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,16 +583,19 @@ async def migrate_nvram(self) -> bool:
583583

584584
return True
585585

586-
async def reset(self) -> None:
586+
async def reset(self, *, wait_for_reset: bool = True) -> None:
587587
"""
588588
Performs a soft reset within Z-Stack.
589589
A hard reset resets the serial port, causing the device to disconnect.
590590
"""
591591

592-
await self.request_callback_rsp(
593-
request=c.SYS.ResetReq.Req(Type=t.ResetType.Soft),
594-
callback=c.SYS.ResetInd.Callback(partial=True),
595-
)
592+
if wait_for_reset:
593+
await self.request_callback_rsp(
594+
request=c.SYS.ResetReq.Req(Type=t.ResetType.Soft),
595+
callback=c.SYS.ResetInd.Callback(partial=True),
596+
)
597+
else:
598+
await self.request(c.SYS.ResetReq.Req(Type=t.ResetType.Soft))
596599

597600
@property
598601
def _port_path(self) -> str:

zigpy_znp/zigbee/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def disconnect(self):
122122

123123
if self._znp is not None:
124124
try:
125-
await self._znp.reset()
125+
await self._znp.reset(wait_for_reset=False)
126126
finally:
127127
self._znp.close()
128128
self._znp = None

0 commit comments

Comments
 (0)