From 2a0516ec836e9458a971cadfcdca90f16a07ca8a Mon Sep 17 00:00:00 2001 From: seiichiro Date: Thu, 19 Sep 2019 18:14:51 +0000 Subject: [PATCH] Added Decoder JS Code --- Firmware/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Firmware/README.md b/Firmware/README.md index e515b87..e22bf71 100644 --- a/Firmware/README.md +++ b/Firmware/README.md @@ -3,4 +3,22 @@ Example Sensor Node Firmware with a BMP/E280 Sensor. Please Change the Values in src/secconfig.h to your Keys from https://console.thethingsnetwork.org. Device has to be set to ABP Mode. -Project was created using PlatformIO Atmel-AVR Framework \ No newline at end of file +Project was created using PlatformIO Atmel-AVR Framework + +## Decoder for the TTN Application + +``` +function Decoder(bytes, port) { + var decoded = {}; + decoded.t = (bytes[0]) | (bytes[1] << 8 ) | (bytes[2] << 16 ) | (bytes[3] << 24) + decoded.t = decoded.t / 100 + decoded.p = (bytes[4]) | (bytes[5] << 8 ) | (bytes[6] << 16 ) | (bytes[7] << 24) + decoded.p = decoded.p / 100 + decoded.h = (bytes[8]) | (bytes[9] << 8 ) | (bytes[10] << 16 ) | (bytes[11] << 24) + decoded.h = decoded.h / 100 + decoded.v = (bytes[12]) | (bytes[13] << 8 ) | (bytes[14] << 16 ) | (bytes[15] << 24) + decoded.v = decoded.v / 1000 + + return decoded; +} +``` \ No newline at end of file