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
这个提交包含在:
@@ -151,7 +151,7 @@ function readDeviceInfo() {
|
|||||||
|
|
||||||
function setParams(options) {
|
function setParams(options) {
|
||||||
if (protocol.PROTOCOL_MODE === 'vendor_33') {
|
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
|
var regionMask = options.region_mask || protocol.REGION.FULL_FACE
|
||||||
|
|||||||
@@ -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('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct, fitting: parsed.fitting, run_state: parsed.run_state })
|
||||||
emit('battery', { battery: batteryPct, vbat: vbatMv })
|
emit('battery', { battery: batteryPct, vbat: vbatMv })
|
||||||
if (parsed.fitting !== -1) {
|
emit('fitting', { fitting: parsed.fitting })
|
||||||
emit('fitting', { fitting: parsed.fitting })
|
emit('run_state', { run_state: parsed.run_state })
|
||||||
}
|
|
||||||
if (parsed.run_state !== -1) {
|
|
||||||
emit('run_state', { run_state: parsed.run_state })
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ module.exports = {
|
|||||||
buildFrame: protocol.buildFrame,
|
buildFrame: protocol.buildFrame,
|
||||||
parseFrame: protocol.parseFrame,
|
parseFrame: protocol.parseFrame,
|
||||||
buildVendorCommand: protocol.buildVendorCommand,
|
buildVendorCommand: protocol.buildVendorCommand,
|
||||||
buildVendorCommand33: protocol.buildVendorCommand33,
|
|
||||||
parseVendorStatus: protocol.parseVendorStatus,
|
parseVendorStatus: protocol.parseVendorStatus,
|
||||||
parseStatusReport: protocol.parseStatusReport,
|
parseStatusReport: protocol.parseStatusReport,
|
||||||
parseAck: protocol.parseAck,
|
parseAck: protocol.parseAck,
|
||||||
|
|||||||
@@ -206,11 +206,6 @@ function buildVendorCommand(options) {
|
|||||||
return bytes
|
return bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated: alias kept for backward compat, actually outputs 34 bytes
|
|
||||||
function buildVendorCommand33(options) {
|
|
||||||
return buildVendorCommand(options)
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseVendorStatus(buffer) {
|
function parseVendorStatus(buffer) {
|
||||||
var bytes = bufferToBytes(buffer)
|
var bytes = bufferToBytes(buffer)
|
||||||
if (bytes.length === 1) {
|
if (bytes.length === 1) {
|
||||||
@@ -233,23 +228,6 @@ function parseVendorStatus(buffer) {
|
|||||||
raw_hex: bytesToHex(bytes)
|
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) {
|
if (bytes.length === 34) {
|
||||||
var ios34 = []
|
var ios34 = []
|
||||||
for (var j = 0; j < 5; j++) {
|
for (var j = 0; j < 5; j++) {
|
||||||
@@ -272,28 +250,6 @@ function parseVendorStatus(buffer) {
|
|||||||
raw_hex: bytesToHex(bytes)
|
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) }
|
return { type: 'unknown', is_heartbeat: false, raw_bytes: bytes, raw_hex: bytesToHex(bytes) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +373,6 @@ module.exports = {
|
|||||||
hexToBytes: hexToBytes,
|
hexToBytes: hexToBytes,
|
||||||
bytesToHex: bytesToHex,
|
bytesToHex: bytesToHex,
|
||||||
buildVendorCommand: buildVendorCommand,
|
buildVendorCommand: buildVendorCommand,
|
||||||
buildVendorCommand33: buildVendorCommand33,
|
|
||||||
|
|
||||||
buildFrame: buildFrame,
|
buildFrame: buildFrame,
|
||||||
parseFrame: parseFrame,
|
parseFrame: parseFrame,
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户