docs: SUOTA 状态码分层与 0x38000 产品头阻断根因入 DECISIONS

This commit is contained in:
agent committed 2026-07-29 04:56:12 +00:00
1 parent ff9f2f84fd
commit 94fea411a9
2 files changed
+16 -4

No files matched your search

+13 -4
View File
@@ -26,16 +26,20 @@ class Bridge:
self.next_id = 0
async def open(self):
try:
self.w.close()
except Exception:
pass
self.r, self.w = await asyncio.open_connection(HOST, PORT)
async def rpc(self, op, timeout=120, **kw):
async def rpc(self, op, wait=120, **kw):
self.next_id += 1
rid = self.next_id
self.w.write(json.dumps({"id": rid, "op": op, **kw}).encode() + b"\n")
await self.w.drain()
events = []
while True:
line = await asyncio.wait_for(self.r.readline(), timeout)
line = await asyncio.wait_for(self.r.readline(), wait)
if not line:
raise ConnectionError("bridge EOF")
msg = json.loads(line)
@@ -46,8 +50,13 @@ class Bridge:
async def connect_until_awake(self, tries=12):
for i in range(tries):
resp, _ = await self.rpc("connect", 150, address=DEVICE,
timeout=30, subscribe=False)
try:
resp, _ = await self.rpc("connect", 150, address=DEVICE,
timeout=30, subscribe=False)
except (ConnectionError, asyncio.TimeoutError):
print(" 连接通道中断,重开 TCP...")
await self.open()
continue
if resp.get("ok"):
print(f"连接成功(第 {i + 1} 次)")
return True