From bad851a1ddecaa1a4d650c9435e81bd956bc452c Mon Sep 17 00:00:00 2001 From: Laziz Turakulov <4857092+LazaUK@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:42:53 +0100 Subject: [PATCH] Add files via upload --- Helium_Function/Helium_Decoder.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Helium_Function/Helium_Decoder.js b/Helium_Function/Helium_Decoder.js index 8b13789..1c565dd 100644 --- a/Helium_Function/Helium_Decoder.js +++ b/Helium_Function/Helium_Decoder.js @@ -1 +1,20 @@ - +function Decoder(bytes, port) { + + var decoded = {}; + + function transformers(bytes){ + value = bytes[0] * 256 + bytes[1]; + if (value >= 32768) { + value = 32768 - value; + } + value = value/100.0; + return value; + } + + if (port == 8) { + decoded.generator_temperature = transformers(bytes.slice(0, 2)); + decoded.generator_humidity = transformers(bytes.slice(2, 4)); + } + + return decoded; +} \ No newline at end of file