From d180a56fd1e305325b9685488f97a83668acb1f7 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 1 Mar 2020 16:18:17 +0100 Subject: [PATCH] ex post clean solution for issue #510 --- src/TTN/packed_decoder.js | 2 -- src/TTN/plain_converter.js | 12 +++++++++++- src/TTN/plain_decoder.js | 2 -- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index 291ee8a7..97dfbcde 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -4,8 +4,6 @@ function Decoder(bytes, port) { var decoded = {}; - decoded.wifi = 0; - decoded.ble = 0; if (bytes.length === 0) { return {}; diff --git a/src/TTN/plain_converter.js b/src/TTN/plain_converter.js index 1302d56c..5845e827 100644 --- a/src/TTN/plain_converter.js +++ b/src/TTN/plain_converter.js @@ -4,14 +4,24 @@ function Converter(decoded, port) { var converted = decoded; + var pax = 0; if (port === 1) { - converted.pax = converted.ble + converted.wifi; + + if ('wifi' in converted) { + pax += converted.wifi + } + if ('ble' in converted) { + pax += converted.ble + } + converted.pax = pax; + if (converted.hdop) { converted.hdop /= 100; converted.latitude /= 1000000; converted.longitude /= 1000000; } + } return converted; diff --git a/src/TTN/plain_decoder.js b/src/TTN/plain_decoder.js index 4e1a7a17..4f7e3429 100644 --- a/src/TTN/plain_decoder.js +++ b/src/TTN/plain_decoder.js @@ -3,8 +3,6 @@ function Decoder(bytes, port) { var decoded = {}; - decoded.wifi = 0; - decoded.ble = 0; if (port === 1) { var i = 0;