From af034105282f793cd3c237a2bd29b756bb7c7073 Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Thu, 2 Apr 2026 11:44:05 +0800 Subject: [PATCH] fix(provision): emit network-ready when AP mode gains internet (e.g. Ethernet) Monitor previously only closed AP on external WiFi STA; late wired uplink while in AP never fired network-ready, so WS stayed down and AP display kept flashing. Poll hasInternet() in AP state and call _emitNetworkReady(). Made-with: Cursor --- lib/provisioning.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/provisioning.js b/lib/provisioning.js index 065f4e2..009b80f 100644 --- a/lib/provisioning.js +++ b/lib/provisioning.js @@ -26,6 +26,8 @@ class ProvisionManager extends EventEmitter { super(); this._clawId = clawId || 'Setup'; this._state = 'idle'; // 'idle' | 'ap' | 'connecting' | 'sta' + /** AP 态下首次检测到外网时打一次日志(如后接网线) */ + this._loggedApInternet = false; this._dns = null; this._server = null; this._monitorTimer = null; @@ -122,6 +124,8 @@ class ProvisionManager extends EventEmitter { _enterAP() { if (this._state === 'ap') return; + this._loggedApInternet = false; + led.off(); // AP 模式:WiFi 未连接,WiFi 灯熄灭 if (!hasInternet()) led.display.showAP(); // 无网时立即显示 AP,有线时等 WS 连接后再定 @@ -219,6 +223,19 @@ class ProvisionManager extends EventEmitter { this.emit('network-ready'); } + // 已在 AP、后接网线等获得外网:此前未发 network-ready,此处补齐(热点可保留供 WiFi 配网) + if (this._state === 'ap') { + if (!hasInternet()) { + this._loggedApInternet = false; + } else { + if (!this._loggedApInternet) { + log.info('provision', 'AP 模式下已具备外网(如已接网线),通知连云'); + this._loggedApInternet = true; + } + this._emitNetworkReady(); + } + } + // 产品 WiFi 灯(OpenVFD wifi+eth):AP 全程强制熄灭,避免与其它逻辑竞态导致误亮 if (this._state === 'ap') { led.off();