From b602adcc12437cec1f899fd630c3fb639deac34c Mon Sep 17 00:00:00 2001 From: Yunhorn Date: Tue, 19 Dec 2023 19:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'decoder.txt'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- decoder.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 decoder.txt diff --git a/decoder.txt b/decoder.txt new file mode 100644 index 0000000..4552e19 --- /dev/null +++ b/decoder.txt @@ -0,0 +1,31 @@ +function Decode(fPort, data, variables) { + if (fPort === 20) { + return [ + { + led_state: bytes[0]===0?"Off":"On", + mtm_code_1:bytes[1], + mtm_code_2:bytes[2], + hw_code:bytes[3], + battery_level:bytes[4]+"%", + size_value:bytes[5], + duration: bytes[6]+"Sec", + x_freq: (bytes[7] << 8 | bytes[8])+" Hz", + y_freq: (bytes[9] << 8 | bytes[10])+" Hz", + z_freq: (bytes[11] << 8 | bytes[12])+" Hz", + x_amp: (bytes[13] << 8 | bytes[14])+" Mag", + y_amp: (bytes[15] << 8 | bytes[16])+" Mag", + z_amp: (bytes[17] << 8 | bytes[18])+" Mag" + } + ]; + } + + else if (fPort === 21) { + return [ + { + led_state: bytes[0]===0?"Off":"On", + battery_level: bytes[1]+"%", + } + ]; + } + +}