ESP32-PaxCounter/src/TTN/plain_converter.js

28 lines
542 B
JavaScript
Raw Normal View History

2018-06-17 13:24:20 +02:00
// Converter for device payload encoder "PLAIN"
// copy&paste to TTN Console -> Applications -> PayloadFormat -> Converter
function Converter(decoded, port) {
var converted = decoded;
2020-03-01 16:18:17 +01:00
var pax = 0;
2018-06-17 13:24:20 +02:00
if (port === 1) {
2020-03-01 16:18:17 +01:00
if ('wifi' in converted) {
pax += converted.wifi
}
if ('ble' in converted) {
pax += converted.ble
}
converted.pax = pax;
2018-06-17 13:24:20 +02:00
if (converted.hdop) {
converted.hdop /= 100;
converted.latitude /= 1000000;
converted.longitude /= 1000000;
}
2020-03-01 16:18:17 +01:00
2018-06-17 13:24:20 +02:00
}
return converted;
}