feat(led): OpenVFD sysfs (wifi+eth, alarm, play/lan), skip BT without hci

- Write /sys/class/leds/openvfd led_on/led_off (CLAWD_OPENVFD_PATH)
- WiFi product LED: wifi+eth together; SETUP/APPS -> alarm off/on
- LanLed polls hasWiredCarrier -> play; export led.lan, start/stop from client
- BT monitor only if CLAWD_DISABLE_BT unset and hci* exists (RK3528)
- Display strings remain debug-only (数码管暂不驱动)
- install.sh env template: CLAWD_DISABLE_BT, CLAWD_OPENVFD_PATH comments

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-28 21:35:38 +08:00
parent abd123b3dd
commit 347b19a0c9
3 changed files with 105 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
'use strict';
const fs = require('fs');
const { getNotifySocket } = require('./systemd-env');
const WebSocket = require('ws');
const { execSync, execFileSync } = require('child_process');
@@ -20,6 +21,15 @@ const PING_INTERVAL_MS = 15_000;
const HEARTBEAT_INTERVAL_MS = 10_000; // 心跳间隔10 秒,用于快速感知网络状态
const METRICS_EVERY_N = 3; // 每 N 次心跳采集一次指标(= 30 秒)
/** CLAWD_DISABLE_BT=1 或系统无 hci* 时不启动 bluetoothctl 轮询(如 RK3528 无蓝牙) */
function bluetoothAdapterPresent() {
try {
return fs.readdirSync('/sys/class/bluetooth').some((n) => n.startsWith('hci'));
} catch (_) {
return false;
}
}
class ClawClient {
constructor() {
this._cfg = config.load();
@@ -165,6 +175,7 @@ class ClawClient {
this._clearHeartbeat();
this._clearPing();
if (this._sdTimer) { clearInterval(this._sdTimer); this._sdTimer = null; }
led.lan.stop();
if (this._btMonitor) { this._btMonitor.stop(); this._btMonitor = null; }
if (this._provisionMgr) { this._provisionMgr.stop(); this._provisionMgr = null; }
this._frpc.stop();