Merge pull request #277 from DavideNesi/patch-2

Update plain_decoder.js
This commit is contained in:
Verkehrsrot 2019-02-23 22:14:05 +01:00 committed by GitHub
commit a974ffb0d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ function Decoder(bytes, port) {
if (bytes.length >= 2) { if (bytes.length >= 2) {
decoded.wifi = (bytes[i++] << 8) | bytes[i++];} decoded.wifi = (bytes[i++] << 8) | bytes[i++];}
if (bytes.length >= 4) { if (bytes.length === 4 || bytes.length > 15) {
decoded.ble = (bytes[i++] << 8) | bytes[i++];} decoded.ble = (bytes[i++] << 8) | bytes[i++];}
if (bytes.length > 4) { if (bytes.length > 4) {
@ -61,6 +61,12 @@ function Decoder(bytes, port) {
decoded.air = ((bytes[i++] << 8) | bytes[i++]); decoded.air = ((bytes[i++] << 8) | bytes[i++]);
} }
if (port === 8) {
var i = 0;
if (bytes.length >= 2) {
decoded.battery = (bytes[i++] << 8) | bytes[i++];}
}
return decoded; return decoded;
} }