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.
这个提交包含在:
Guoguo
2026-06-12 08:52:44 -07:00
父节点 7270b593ae
当前提交 69621fd2b6
修改 2 个文件,包含 26 行新增1 行删除
+19
查看文件
@@ -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)
}