From a0f767f2679ba82dc4e2defe2e02e5ef5d7bde45 Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Wed, 18 Mar 2026 20:56:49 +0800 Subject: [PATCH] fix(led): swap SETUP/APPS paths, WiFi LED off in AP mode Made-with: Cursor --- lib/led.js | 4 ++-- lib/provisioning.js | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/led.js b/lib/led.js index 47d268c..bef52be 100644 --- a/lib/led.js +++ b/lib/led.js @@ -18,8 +18,8 @@ const log = require('./logger'); */ const LED_PATH = process.env.CLAWD_LED_PATH || '/sys/devices/platform/openvfd/attr/b5'; -const SETUP_LED_PATH = '/sys/devices/platform/openvfd/attr/b2'; -const APPS_LED_PATH = '/sys/devices/platform/openvfd/attr/b1'; +const SETUP_LED_PATH = '/sys/devices/platform/openvfd/attr/b1'; // 物理 SETUP 灯 +const APPS_LED_PATH = '/sys/devices/platform/openvfd/attr/b2'; // 物理 APPS 灯 const BLINK_INTERVAL_MS = 500; // 闪烁间隔(ms) class WifiLed { diff --git a/lib/provisioning.js b/lib/provisioning.js index e7a4c73..40e78dd 100644 --- a/lib/provisioning.js +++ b/lib/provisioning.js @@ -69,10 +69,11 @@ class ProvisionManager extends EventEmitter { _emitNetworkReady() { if (hasInternet()) { - led.on(); // 网络畅通 → 常亮 + // WiFi 灯只在 STA 模式下亮(有线有网而 WiFi 在 AP 模式时不亮) + if (this._state === 'sta') led.on(); this.emit('network-ready'); } else { - log.warn('provision', 'WiFi 已连接但 hasInternet() 返回 false,LED 保持熄灭'); + log.warn('provision', 'hasInternet() 返回 false,LED 保持熄灭'); } } @@ -183,7 +184,7 @@ class ProvisionManager extends EventEmitter { this.emit('network-ready'); } - // STA 模式下持续监测互联网连通性,实时更新 LED + // WiFi 灯:只在 STA 模式下反映互联网连通性;AP 模式下始终熄灭 if (this._state === 'sta') { if (hasInternet()) { led.on(); @@ -191,6 +192,7 @@ class ProvisionManager extends EventEmitter { led.off(); // WiFi 已连接但无互联网 } } + // AP 模式下 led 已在 _enterAP() 中熄灭,无需重复操作 }, MONITOR_INTERVAL_MS); }