Update README.md

This commit is contained in:
Verkehrsrot 2018-06-10 18:43:56 +02:00 committed by GitHub
parent c6ab2a3dcc
commit 416c0f2119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,13 +137,16 @@ function Decoder(bytes, port) {
var decoded = {}; var decoded = {};
if (port === 1) { if (port === 1) {
decoded.wifi = (bytes[0] << 8) | bytes[1]; var i = 0;
decoded.ble = (bytes[2] << 8) | bytes[3]; decoded.wifi = (bytes[i++] << 8) | bytes[i++];
decoded.latitude = ((bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4]); decoded.ble = (bytes[i++] << 8) | bytes[i++];
decoded.longitude = ((bytes[11] << 24) | (bytes[10] << 16) | (bytes[9] << 8) | bytes[8]); if (bytes.length > 4) {
decoded.sats = (bytes[13] << 8) | bytes[12]; decoded.latitude = ( (bytes[i++]) | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24 );
decoded.hdop = (bytes[15] << 8) | bytes[14]; decoded.longitude = ( (bytes[i++]) | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24 );
decoded.altitude = (bytes[17] << 8) | bytes[16]; decoded.sats = ( bytes[i++] | (bytes[i++] << 8) );
decoded.hdop = ( bytes[i++] | (bytes[i++] << 8) );
decoded.altitude = ( bytes[i++] | (bytes[i++] << 8) );
}
} }
return decoded; return decoded;
@ -154,13 +157,16 @@ Converter:
```javascript ```javascript
function Converter(decoded, port) { function Converter(decoded, port) {
var converted = decoded; var converted = decoded;
if (port === 1) { if (port === 1) {
converted.pax = converted.ble + converted.wifi; converted.pax = converted.ble + converted.wifi;
converted.hdop /= 100; if (converted.length > 4){
converted.latitude /= 1000000; converted.hdop /= 100;
converted.longitude /= 1000000; converted.latitude /= 1000000;
converted.longitude /= 1000000;
}
} }
return converted; return converted;