TTN decoder updates

This commit is contained in:
Verkehrsrot 2019-04-06 21:10:33 +02:00
parent 261c643d7f
commit 11c2fb6fa2
2 changed files with 28 additions and 19 deletions

View File

@ -33,10 +33,6 @@ function Decoder(bytes, port) {
if (bytes.length === 17) {
return decode(bytes, [uint16, uptime, uint8, uint32, uint8, uint8], ['voltage', 'uptime', 'cputemp', 'memory', 'reset0', 'reset1']);
}
// epoch time answer
if (bytes.length === 5) {
return decode(bytes, [uint32, uint8], ['time', 'timestatus']);
}
}
if (port === 3) {
@ -73,9 +69,13 @@ function Decoder(bytes, port) {
// timesync request
if (bytes.length === 1) {
decoded.timesync_seqno = bytes[0];
}
return decoded;
}
// epoch time answer
if (bytes.length === 5) {
return decode(bytes, [uint32, uint8], ['time', 'timestatus']);
}
}
}

View File

@ -8,10 +8,12 @@ function Decoder(bytes, port) {
var i = 0;
if (bytes.length >= 2) {
decoded.wifi = (bytes[i++] << 8) | bytes[i++];}
decoded.wifi = (bytes[i++] << 8) | bytes[i++];
}
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) {
decoded.latitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
@ -64,15 +66,22 @@ function Decoder(bytes, port) {
if (port === 8) {
var i = 0;
if (bytes.length >= 2) {
decoded.battery = (bytes[i++] << 8) | bytes[i++];}
decoded.battery = (bytes[i++] << 8) | bytes[i++];
}
}
if (port === 9) {
// timesync request
if (bytes.length === 1) {
decoded.timesync_seqno = bytes[0];
}
// epoch time answer
if (bytes.length === 5) {
var i = 0;
decoded.time = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
decoded.timestatus = bytes[i++];
}
return decoded;
}
}