feat: support 17-byte ADC status from updated vendor protocol
Protocol update adds FFE4 Status format: 7×PD sensors (little-endian) + VBAT battery voltage (mV) + XOR checksum = 17 bytes. - parseVendorStatus: handles 1-byte heartbeat, 17-byte ADC, 33-byte params - handleValueChange: ADC type extracts PD array + battery % from VBAT - Battery calculated as linear 3000mV(0%) to 4200mV(100%) - PD data passed through status event for treatment pages - Updated protocol doc with full byte table and old/new comparison
这个提交包含在:
@@ -197,7 +197,22 @@ function buildVendorCommand33(options) {
|
||||
function parseVendorStatus(buffer) {
|
||||
var bytes = bufferToBytes(buffer)
|
||||
if (bytes.length === 1) {
|
||||
return { heartbeat: bytes[0], is_heartbeat: true, raw_hex: bytesToHex(bytes) }
|
||||
return { type: 'heartbeat', heartbeat: bytes[0], is_heartbeat: true, raw_hex: bytesToHex(bytes) }
|
||||
}
|
||||
if (bytes.length === 17) {
|
||||
var checksum = xorChecksum(bytes.slice(0, 16))
|
||||
var pds = []
|
||||
for (var p = 0; p < 7; p++) {
|
||||
pds.push(bytes[p * 2] | (bytes[p * 2 + 1] << 8))
|
||||
}
|
||||
return {
|
||||
type: 'adc',
|
||||
is_heartbeat: false,
|
||||
pd: pds,
|
||||
vbat: bytes[14] | (bytes[15] << 8),
|
||||
checksum_ok: checksum === bytes[16],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
if (bytes.length === 33) {
|
||||
var ios = []
|
||||
@@ -210,6 +225,7 @@ function parseVendorStatus(buffer) {
|
||||
})
|
||||
}
|
||||
return {
|
||||
type: 'params',
|
||||
is_heartbeat: false,
|
||||
ios: ios,
|
||||
hold_time: (bytes[30] << 8) | bytes[31],
|
||||
@@ -217,7 +233,7 @@ function parseVendorStatus(buffer) {
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
return { is_heartbeat: false, raw_bytes: bytes, raw_hex: bytesToHex(bytes) }
|
||||
return { type: 'unknown', is_heartbeat: false, raw_bytes: bytes, raw_hex: bytesToHex(bytes) }
|
||||
}
|
||||
|
||||
// --- frame encoding/decoding ---
|
||||
|
||||
在新工单中引用
屏蔽一个用户