ESP32-PaxCounter/src/TTN/packed_converter.js

25 lines
503 B
JavaScript
Raw Normal View History

2018-06-17 22:41:32 +02:00
// Converter for device payload encoder "PACKED"
2018-06-17 13:24:20 +02:00
// copy&paste to TTN Console -> Applications -> PayloadFormat -> Converter
function Converter(decoded, port) {
var converted = decoded;
2018-12-02 14:08:50 +01:00
var pax = 0;
2018-06-17 13:24:20 +02:00
if (port === 1) {
2019-01-01 13:48:32 +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
}
2018-07-09 21:22:04 +02:00
if (port === 2) {
converted.voltage /= 1000;
}
2018-07-15 19:08:18 +02:00
2018-06-17 13:24:20 +02:00
return converted;
}