feat(bridge): build 8 notify 超时+connect subscribe 选项(OTA 净连接)
This commit is contained in:
1 parent
6c46c73c21
commit
cbf7629dc8
2 files changed
+21
-13
No files matched your search
@@ -46,12 +46,13 @@ class BridgeTransport:
|
||||
|
||||
def __init__(self, address: str | None = None, timeout: float = 10.0,
|
||||
*, host: str, port: int = DEFAULT_PORT,
|
||||
name_prefix: str = "NRF-"):
|
||||
name_prefix: str = "NRF-", subscribe: bool = True):
|
||||
self.address = address
|
||||
self.timeout = timeout
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.name_prefix = name_prefix
|
||||
self.subscribe = subscribe # OTA 用 False(净连接,避开订阅抖动)
|
||||
self._reader: asyncio.StreamReader | None = None
|
||||
self._writer: asyncio.StreamWriter | None = None
|
||||
self._reader_task: asyncio.Task | None = None
|
||||
@@ -77,7 +78,8 @@ class BridgeTransport:
|
||||
raise BridgeError(f"bridge 未发现 {self.name_prefix!r} 前缀设备")
|
||||
self.address = devices[0]["address"]
|
||||
await self._rpc("connect", 90.0 + self.timeout,
|
||||
address=self.address, timeout=self.timeout)
|
||||
address=self.address, timeout=self.timeout,
|
||||
subscribe=self.subscribe)
|
||||
except Exception:
|
||||
await self._teardown()
|
||||
raise
|
||||
|
||||
Reference in new issue
Block a user