mirror of
https://github.com/meshtastic/python.git
synced 2026-01-17 04:08:13 -05:00
add a configurable timeout
This commit is contained in:
@@ -275,7 +275,8 @@ def onConnected(interface):
|
||||
|
||||
# convenient place to store any keyword args we pass to getNode
|
||||
getNode_kwargs = {
|
||||
"requestChannelRetries": int(args.channel_fetch_retries)
|
||||
"requestChannelRetries": int(args.channel_fetch_retries),
|
||||
"timeout": int(args.timeout)
|
||||
}
|
||||
|
||||
# do not print this line if we are exporting the config
|
||||
@@ -1434,6 +1435,12 @@ def initParser():
|
||||
default=3,
|
||||
)
|
||||
|
||||
group.add_argument(
|
||||
"--timeout",
|
||||
help="How long to wait for replies",
|
||||
default=300
|
||||
)
|
||||
|
||||
group.add_argument(
|
||||
"--ch-vlongslow",
|
||||
help="Change to the very long-range and slow channel",
|
||||
|
||||
@@ -314,13 +314,13 @@ class MeshInterface: # pylint: disable=R0902
|
||||
return table
|
||||
|
||||
def getNode(
|
||||
self, nodeId: str, requestChannels: bool = True, requestChannelRetries: int = 3
|
||||
self, nodeId: str, requestChannels: bool = True, requestChannelRetries: int = 3, timeout: int = 300
|
||||
) -> meshtastic.node.Node:
|
||||
"""Return a node object which contains device settings and channel info"""
|
||||
if nodeId in (LOCAL_ADDR, BROADCAST_ADDR):
|
||||
return self.localNode
|
||||
else:
|
||||
n = meshtastic.node.Node(self, nodeId)
|
||||
n = meshtastic.node.Node(self, nodeId, timeout=timeout)
|
||||
# Only request device settings and channel info when necessary
|
||||
if requestChannels:
|
||||
logging.debug("About to requestChannels")
|
||||
|
||||
@@ -25,14 +25,14 @@ class Node:
|
||||
Includes methods for localConfig, moduleConfig and channels
|
||||
"""
|
||||
|
||||
def __init__(self, iface, nodeNum, noProto=False):
|
||||
def __init__(self, iface, nodeNum, noProto=False, timeout: int = 300):
|
||||
"""Constructor"""
|
||||
self.iface = iface
|
||||
self.nodeNum = nodeNum
|
||||
self.localConfig = localonly_pb2.LocalConfig()
|
||||
self.moduleConfig = localonly_pb2.LocalModuleConfig()
|
||||
self.channels = None
|
||||
self._timeout = Timeout(maxSecs=300)
|
||||
self._timeout = Timeout(maxSecs=timeout)
|
||||
self.partialChannels = None
|
||||
self.noProto = noProto
|
||||
self.cannedPluginMessage = None
|
||||
|
||||
Reference in New Issue
Block a user