REVISED DECODER.JS

This commit is contained in:
Yunhorn 2023-12-20 18:57:50 +08:00
parent fd0b503e1a
commit c0d7a5ac58
1 changed files with 57 additions and 18 deletions

View File

@ -29,4 +29,43 @@ function Decode(fPort, data, variables) {
}
];
}
else if (fPort === 1) {
if (bytes[0] === 0x56) {
return [
{
mtm_code_1: bytes[1],
mtm_code_2: bytes[2],
HW_Version: "HW:" + bytes[3],
SW_Version: "SW" + bytes[4] + ":" + bytes[5] + ":" + bytes[6] + ":" + bytes[7],
}
];
}
else if (bytes[0] === 0x53) {
return [
{
mtm_code_1: bytes[1],
mtm_code_2: bytes[2],
sw_code: bytes[3],
hw_code: bytes[4],
battery_level: bytes[5] + "%",
size_value: bytes[6],
}
];
}
if (bytes[0] === 0x59) {
if (bytes[1] === 0x44) {
return [
{
HB_interval: (bytes[2] - 0x30) * 10 + (bytes[3] - 0x30),
HB_interval_unit: String.fromCharCode(bytes[4]),
}
];
}
}
}
};