Undo merge

This commit is contained in:
Oliver Brandmueller committed 2019-01-19 19:54:54 +01:00
1 parent d9404b1a32
commit 7bdff00161
60 files changed
+1911 -1679

No files matched your search

+9 -2
View File
@@ -4,15 +4,22 @@
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 (port === 2) {
converted.voltage /= 1000;
}
return converted;
}
+19 -2
View File
@@ -5,12 +5,24 @@ function Decoder(bytes, port) {
var decoded = {};
if (bytes.length === 0) {
return {};
}
if (port === 1) {
// only counter data, no gps
// only wifi counter data, no gps
if (bytes.length === 2) {
return decode(bytes, [uint16], ['wifi']);
}
// wifi + ble counter data, no gps
if (bytes.length === 4) {
return decode(bytes, [uint16, uint16], ['wifi', 'ble']);
}
// combined counter and gps data
// combined wifi counter and gps data
if (bytes.length === 15) {
return decode(bytes, [uint16, latLng, latLng, uint8, hdop, uint16], ['wifi', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
}
// combined wifi + ble counter and gps data
if (bytes.length === 17) {
return decode(bytes, [uint16, uint16, latLng, latLng, uint8, hdop, uint16], ['wifi', 'ble', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
}
@@ -46,6 +58,11 @@ function Decoder(bytes, port) {
return decode(bytes, [float, uint16, ufloat, ufloat], ['temperature', 'pressure', 'humidity', 'air']);
}
if (port === 8) {
// battery voltage
return decode(bytes, [uint16], ['voltage']);
}
}
+5 -2
View File
@@ -7,8 +7,11 @@ function Decoder(bytes, port) {
if (port === 1) {
var i = 0;
decoded.wifi = (bytes[i++] << 8) | bytes[i++];
decoded.ble = (bytes[i++] << 8) | bytes[i++];
if (bytes.length >= 2) {
decoded.wifi = (bytes[i++] << 8) | bytes[i++];}
if (bytes.length >= 4) {
decoded.ble = (bytes[i++] << 8) | bytes[i++];}
if (bytes.length > 4) {
decoded.latitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);