fix: ADC notifications no longer emit 'status' (prevents timer jump)

- ADC (17-byte) now emits 'adc' + 'battery' events, not 'status'
- Fixes CRITICAL timer jump: remaining_ms:0 was resetting countdown
- Drop ADC packets with bad XOR checksum
- treating.js + index.js subscribe to 'battery' for live battery updates
- onStatus only updates remaining_ms when > 0
这个提交包含在:
Guoguo
2026-05-19 03:57:47 -07:00
父节点 3fd7578163
当前提交 f1a2523cb4
修改 3 个文件,包含 28 行新增18 行删除
+6 -14
查看文件
@@ -94,20 +94,12 @@ function handleValueChange(res) {
if (parsed.type === 'adc') {
var vbatMv = parsed.vbat
var batteryPct = Math.min(100, Math.max(0, Math.round((vbatMv - 3000) / (4200 - 3000) * 100)))
emit('status', {
mode_state: protocol.MODE_STATE.ACTIVE,
region_mask: protocol.REGION.FULL_FACE,
wavelength: 0,
brightness: 0,
remaining_ms: 0,
error_code: 0,
battery: batteryPct,
temperature: 0,
bind_status: 1,
subscription: 1,
pd: parsed.pd,
vbat: vbatMv
})
if (!parsed.checksum_ok) {
console.warn('[BLE] ADC checksum mismatch, dropping')
return
}
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct })
emit('battery', { battery: batteryPct, vbat: vbatMv })
return
}