fix(led): swap SETUP/APPS paths, WiFi LED off in AP mode

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-18 20:56:49 +08:00
parent 90bba5f348
commit a0f767f267
2 changed files with 7 additions and 5 deletions

View File

@@ -18,8 +18,8 @@ const log = require('./logger');
*/ */
const LED_PATH = process.env.CLAWD_LED_PATH || '/sys/devices/platform/openvfd/attr/b5'; 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 SETUP_LED_PATH = '/sys/devices/platform/openvfd/attr/b1'; // 物理 SETUP 灯
const APPS_LED_PATH = '/sys/devices/platform/openvfd/attr/b1'; const APPS_LED_PATH = '/sys/devices/platform/openvfd/attr/b2'; // 物理 APPS 灯
const BLINK_INTERVAL_MS = 500; // 闪烁间隔ms const BLINK_INTERVAL_MS = 500; // 闪烁间隔ms
class WifiLed { class WifiLed {

View File

@@ -69,10 +69,11 @@ class ProvisionManager extends EventEmitter {
_emitNetworkReady() { _emitNetworkReady() {
if (hasInternet()) { if (hasInternet()) {
led.on(); // 网络畅通 → 常亮 // WiFi 灯只在 STA 模式下亮(有线有网而 WiFi 在 AP 模式时不亮)
if (this._state === 'sta') led.on();
this.emit('network-ready'); this.emit('network-ready');
} else { } else {
log.warn('provision', 'WiFi 已连接但 hasInternet() 返回 falseLED 保持熄灭'); log.warn('provision', 'hasInternet() 返回 falseLED 保持熄灭');
} }
} }
@@ -183,7 +184,7 @@ class ProvisionManager extends EventEmitter {
this.emit('network-ready'); this.emit('network-ready');
} }
// STA 模式下持续监测互联网连通性,实时更新 LED // WiFi 灯:只在 STA 模式下反映互联网连通性AP 模式下始终熄灭
if (this._state === 'sta') { if (this._state === 'sta') {
if (hasInternet()) { if (hasInternet()) {
led.on(); led.on();
@@ -191,6 +192,7 @@ class ProvisionManager extends EventEmitter {
led.off(); // WiFi 已连接但无互联网 led.off(); // WiFi 已连接但无互联网
} }
} }
// AP 模式下 led 已在 _enterAP() 中熄灭,无需重复操作
}, MONITOR_INTERVAL_MS); }, MONITOR_INTERVAL_MS);
} }