From c13ed3ba6d5a3fd56e2d6536f5543e7bf768d9ed Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:45:16 +0800 Subject: [PATCH] fix(vfd): use isApMode() instead of hasInternet() to decide AP vs Err0 Made-with: Cursor --- lib/client.js | 7 ++++--- lib/provisioning.js | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 4170bea..c8da8f5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -163,10 +163,11 @@ class ClawClient { this._wsFailCount++; log.warn('clawd', `连接断开 (${code}),失败次数=${this._wsFailCount},${this._backoff / 1000}s 后重连...`); if (this._hasEverConnected && this._wsFailCount >= 3) { - if (hasInternet()) { - led.display.showErr0(); // 有网但 VPS 不可达 + const inAp = this._provisionMgr && this._provisionMgr.isApMode(); + if (inAp || !hasInternet()) { + led.display.showAP(); // AP 模式 或 无网 } else { - led.display.showAP(); // 无网,AP 模式 + led.display.showErr0(); // STA 模式 + 有网 但 VPS 不可达 } } setTimeout(() => this._connect(), this._backoff); diff --git a/lib/provisioning.js b/lib/provisioning.js index 1ece1a2..e3ab333 100644 --- a/lib/provisioning.js +++ b/lib/provisioning.js @@ -31,6 +31,9 @@ class ProvisionManager extends EventEmitter { this._monitorTimer = null; } + /** 是否正处于 AP 模式(WiFi 热点广播中) */ + isApMode() { return this._state === 'ap'; } + async start() { led.off(); // 初始状态:灭灯