mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Use firmware suggested_timeout for login and path discovery sync methods
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ed96df197a
commit
5e9cb559e7
1 changed files with 6 additions and 2 deletions
|
|
@ -34,12 +34,14 @@ class MessagingCommands(CommandHandlerBase):
|
|||
logger.warning("*** please consider using send_login_sync instead of send_login")
|
||||
return await self._send_login_raw(dst, pwd)
|
||||
|
||||
async def send_login_sync(self, dst: DestinationType, pwd: str, timeout: float = 10.0) -> Optional[Event]:
|
||||
async def send_login_sync(self, dst: DestinationType, pwd: str, timeout=0, min_timeout=0) -> Optional[Event]:
|
||||
"""Send login to a remote node and wait for the response."""
|
||||
async with self._mesh_request_lock:
|
||||
result = await self._send_login_raw(dst, pwd)
|
||||
if result is None or result.type == EventType.ERROR:
|
||||
return None
|
||||
timeout = result.payload["suggested_timeout"] / 800 if timeout == 0 else timeout
|
||||
timeout = timeout if timeout > min_timeout else min_timeout
|
||||
login_event = await self.dispatcher.wait_for_event(
|
||||
EventType.LOGIN_SUCCESS,
|
||||
timeout=timeout,
|
||||
|
|
@ -199,12 +201,14 @@ class MessagingCommands(CommandHandlerBase):
|
|||
logger.warning("*** please consider using send_path_discovery_sync instead of send_path_discovery")
|
||||
return await self._send_path_discovery_raw(dst)
|
||||
|
||||
async def send_path_discovery_sync(self, dst: DestinationType, timeout: float = 30.0) -> Optional[Event]:
|
||||
async def send_path_discovery_sync(self, dst: DestinationType, timeout=0, min_timeout=0) -> Optional[Event]:
|
||||
"""Send path discovery request and wait for the response."""
|
||||
async with self._mesh_request_lock:
|
||||
result = await self._send_path_discovery_raw(dst)
|
||||
if result is None or result.type == EventType.ERROR:
|
||||
return None
|
||||
timeout = result.payload["suggested_timeout"] / 800 if timeout == 0 else timeout
|
||||
timeout = timeout if timeout > min_timeout else min_timeout
|
||||
path_event = await self.dispatcher.wait_for_event(
|
||||
EventType.PATH_RESPONSE,
|
||||
timeout=timeout,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue