fix(led): use log.info for LED state, show write errors and hasInternet failures

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-18 20:07:31 +08:00
parent 875e69a454
commit b95e909d48
2 changed files with 7 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ class WifiLed {
this._stopBlink();
this._write(1);
this._current = 'on';
log.debug('led', 'WiFi 指示灯 → 常亮');
log.info('led', 'WiFi 指示灯 → 常亮');
}
/** 熄灭 */
@@ -40,7 +40,7 @@ class WifiLed {
this._stopBlink();
this._write(0);
this._current = 'off';
log.debug('led', 'WiFi 指示灯 → 熄灭');
log.info('led', 'WiFi 指示灯 → 熄灭');
}
/** 闪烁(连接中) */
@@ -54,7 +54,7 @@ class WifiLed {
this._write(this._blinkState ? 1 : 0);
}, intervalMs);
this._current = 'blink';
log.debug('led', 'WiFi 指示灯 → 闪烁');
log.info('led', 'WiFi 指示灯 → 闪烁');
}
/** 释放资源,关灯 */
@@ -76,8 +76,8 @@ class WifiLed {
_write(val) {
try {
fs.writeFileSync(LED_PATH, String(val));
} catch (_) {
// 设备不支持 openvfd 时静默忽略(开发机上不会报错)
} catch (e) {
log.warn('led', `写入失败 (${LED_PATH}): ${e.message}`);
}
}
}

View File

@@ -71,6 +71,8 @@ class ProvisionManager extends EventEmitter {
if (hasInternet()) {
led.on(); // 网络畅通 → 常亮
this.emit('network-ready');
} else {
log.warn('provision', 'WiFi 已连接但 hasInternet() 返回 falseLED 保持熄灭');
}
}