refactor: remove 17-byte FFE4 and 33-byte FFE1 legacy compat code

- Remove parseVendorStatus 17-byte branch (FFE4 is now 19 bytes)
- Remove parseVendorStatus 33-byte branch (FFE1 is now 34 bytes)
- Remove buildVendorCommand33 deprecated alias
- Remove fitting/run_state !== -1 guards in connection.js
- Update commands.js to use buildVendorCommand directly
这个提交包含在:
Guoguo
2026-06-24 05:13:36 -07:00
父节点 29975c6043
当前提交 ec5b8584ec
修改 4 个文件,包含 3 行新增53 行删除
+1 -1
查看文件
@@ -151,7 +151,7 @@ function readDeviceInfo() {
function setParams(options) {
if (protocol.PROTOCOL_MODE === 'vendor_33') {
return writeRawCommand(protocol.buildVendorCommand33(options || {}))
return writeRawCommand(protocol.buildVendorCommand(options || {}))
}
var regionMask = options.region_mask || protocol.REGION.FULL_FACE
-4
查看文件
@@ -101,12 +101,8 @@ function handleValueChange(res) {
}
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
}
-1
查看文件
@@ -43,7 +43,6 @@ module.exports = {
buildFrame: protocol.buildFrame,
parseFrame: protocol.parseFrame,
buildVendorCommand: protocol.buildVendorCommand,
buildVendorCommand33: protocol.buildVendorCommand33,
parseVendorStatus: protocol.parseVendorStatus,
parseStatusReport: protocol.parseStatusReport,
parseAck: protocol.parseAck,
-45
查看文件
@@ -206,11 +206,6 @@ function buildVendorCommand(options) {
return bytes
}
// deprecated: alias kept for backward compat, actually outputs 34 bytes
function buildVendorCommand33(options) {
return buildVendorCommand(options)
}
function parseVendorStatus(buffer) {
var bytes = bufferToBytes(buffer)
if (bytes.length === 1) {
@@ -233,23 +228,6 @@ function parseVendorStatus(buffer) {
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),
fitting: -1,
run_state: -1,
checksum_ok: checksum === bytes[16],
raw_hex: bytesToHex(bytes)
}
}
if (bytes.length === 34) {
var ios34 = []
for (var j = 0; j < 5; j++) {
@@ -272,28 +250,6 @@ function parseVendorStatus(buffer) {
raw_hex: bytesToHex(bytes)
}
}
if (bytes.length === 33) {
var ios = []
for (var i = 0; i < 5; i++) {
var off = i * 6
ios.push({
red: bytes[off], infrared: bytes[off + 1],
uv: bytes[off + 2], warm_yellow: bytes[off + 3],
gain: (bytes[off + 4] << 8) | bytes[off + 5]
})
}
var expected33 = xorChecksum(bytes.slice(0, 32))
return {
type: 'params',
is_heartbeat: false,
ios: ios,
hold_time: (bytes[30] << 8) | bytes[31],
control: -1,
checksum: bytes[32],
checksum_ok: expected33 === bytes[32],
raw_hex: bytesToHex(bytes)
}
}
return { type: 'unknown', is_heartbeat: false, raw_bytes: bytes, raw_hex: bytesToHex(bytes) }
}
@@ -417,7 +373,6 @@ module.exports = {
hexToBytes: hexToBytes,
bytesToHex: bytesToHex,
buildVendorCommand: buildVendorCommand,
buildVendorCommand33: buildVendorCommand33,
buildFrame: buildFrame,
parseFrame: parseFrame,