fix(led): use log.info for LED state, show write errors and hasInternet failures
Made-with: Cursor
This commit is contained in:
10
lib/led.js
10
lib/led.js
@@ -31,7 +31,7 @@ class WifiLed {
|
|||||||
this._stopBlink();
|
this._stopBlink();
|
||||||
this._write(1);
|
this._write(1);
|
||||||
this._current = 'on';
|
this._current = 'on';
|
||||||
log.debug('led', 'WiFi 指示灯 → 常亮');
|
log.info('led', 'WiFi 指示灯 → 常亮');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 熄灭 */
|
/** 熄灭 */
|
||||||
@@ -40,7 +40,7 @@ class WifiLed {
|
|||||||
this._stopBlink();
|
this._stopBlink();
|
||||||
this._write(0);
|
this._write(0);
|
||||||
this._current = 'off';
|
this._current = 'off';
|
||||||
log.debug('led', 'WiFi 指示灯 → 熄灭');
|
log.info('led', 'WiFi 指示灯 → 熄灭');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 闪烁(连接中) */
|
/** 闪烁(连接中) */
|
||||||
@@ -54,7 +54,7 @@ class WifiLed {
|
|||||||
this._write(this._blinkState ? 1 : 0);
|
this._write(this._blinkState ? 1 : 0);
|
||||||
}, intervalMs);
|
}, intervalMs);
|
||||||
this._current = 'blink';
|
this._current = 'blink';
|
||||||
log.debug('led', 'WiFi 指示灯 → 闪烁');
|
log.info('led', 'WiFi 指示灯 → 闪烁');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 释放资源,关灯 */
|
/** 释放资源,关灯 */
|
||||||
@@ -76,8 +76,8 @@ class WifiLed {
|
|||||||
_write(val) {
|
_write(val) {
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(LED_PATH, String(val));
|
fs.writeFileSync(LED_PATH, String(val));
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
// 设备不支持 openvfd 时静默忽略(开发机上不会报错)
|
log.warn('led', `写入失败 (${LED_PATH}): ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ class ProvisionManager extends EventEmitter {
|
|||||||
if (hasInternet()) {
|
if (hasInternet()) {
|
||||||
led.on(); // 网络畅通 → 常亮
|
led.on(); // 网络畅通 → 常亮
|
||||||
this.emit('network-ready');
|
this.emit('network-ready');
|
||||||
|
} else {
|
||||||
|
log.warn('provision', 'WiFi 已连接但 hasInternet() 返回 false,LED 保持熄灭');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user