feat: support FFE4 19-byte format with fitting and run_state fields
Per 协议简述(3): FFE4 now 19 bytes — adds Byte17 fitting status (0=not fitted, 1=fitted) and Byte18 run state (0=IDLE, 1=scanning, 2=treating, FF=fault). Maintains backward compat with 17-byte format.
这个提交包含在:
@@ -98,8 +98,14 @@ function handleValueChange(res) {
|
||||
console.warn('[BLE] ADC checksum mismatch, dropping')
|
||||
return
|
||||
}
|
||||
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct })
|
||||
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct, fitting: parsed.fitting, run_state: parsed.run_state })
|
||||
emit('battery', { battery: batteryPct, vbat: vbatMv })
|
||||
if (parsed.fitting !== -1) {
|
||||
emit('fitting', { fitting: parsed.fitting })
|
||||
}
|
||||
if (parsed.run_state !== -1) {
|
||||
emit('run_state', { run_state: parsed.run_state })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,23 @@ function parseVendorStatus(buffer) {
|
||||
if (bytes.length === 1) {
|
||||
return { type: 'heartbeat', heartbeat: bytes[0], is_heartbeat: true, raw_hex: bytesToHex(bytes) }
|
||||
}
|
||||
if (bytes.length === 19) {
|
||||
var checksum19 = xorChecksum(bytes.slice(0, 18))
|
||||
var pds19 = []
|
||||
for (var p = 0; p < 7; p++) {
|
||||
pds19.push(bytes[p * 2] | (bytes[p * 2 + 1] << 8))
|
||||
}
|
||||
return {
|
||||
type: 'adc',
|
||||
is_heartbeat: false,
|
||||
pd: pds19,
|
||||
vbat: bytes[14] | (bytes[15] << 8),
|
||||
fitting: bytes[16],
|
||||
run_state: bytes[17],
|
||||
checksum_ok: checksum19 === bytes[18],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
if (bytes.length === 17) {
|
||||
var checksum = xorChecksum(bytes.slice(0, 16))
|
||||
var pds = []
|
||||
@@ -210,6 +227,8 @@ function parseVendorStatus(buffer) {
|
||||
is_heartbeat: false,
|
||||
pd: pds,
|
||||
vbat: bytes[14] | (bytes[15] << 8),
|
||||
fitting: -1,
|
||||
run_state: -1,
|
||||
checksum_ok: checksum === bytes[16],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户