TTN decoders updated
This commit is contained in:
parent
836572eeb2
commit
52efcb7b01
@ -18,12 +18,12 @@ function Decoder(bytes, port) {
|
||||
|
||||
if (port === 2) {
|
||||
// device status data
|
||||
return decode(bytes, [uint16, uptime, uint8, uint32], ['voltage', 'uptime', 'cputemp', 'memory']);
|
||||
return decode(bytes, [uint16, uptime, uint8, uint32, uint8, uint8], ['voltage', 'uptime', 'cputemp', 'memory', 'reset0', 'reset1']);
|
||||
}
|
||||
|
||||
if (port === 3) {
|
||||
// device config data
|
||||
return decode(bytes, [uint8, uint8, uint16, uint8, uint8, uint8, uint8, bitmap], ['lorasf', 'txpower', 'rssilimit', 'sendcycle', 'wifichancycle', 'blescantime', 'rgblum', 'flags']);
|
||||
return decode(bytes, [uint8, uint8, uint16, uint8, uint8, uint8, uint8, bitmap, version], ['lorasf', 'txpower', 'rssilimit', 'sendcycle', 'wifichancycle', 'blescantime', 'rgblum', 'flags', 'version']);
|
||||
}
|
||||
|
||||
if (port === 4) {
|
||||
@ -55,6 +55,14 @@ var bytesToInt = function (bytes) {
|
||||
return i;
|
||||
};
|
||||
|
||||
var version = function (bytes) {
|
||||
if (bytes.length !== version.BYTES) {
|
||||
throw new Error('version must have exactly 10 bytes');
|
||||
}
|
||||
return String.fromCharCode.apply(null, bytes).split('\u0000')[0];
|
||||
};
|
||||
version.BYTES = 10;
|
||||
|
||||
var uint8 = function (bytes) {
|
||||
if (bytes.length !== uint8.BYTES) {
|
||||
throw new Error('uint8 must have exactly 1 byte');
|
||||
@ -180,12 +188,12 @@ if (typeof module === 'object' && typeof module.exports !== 'undefined') {
|
||||
uint16: uint16,
|
||||
uint32: uint32,
|
||||
uptime: uptime,
|
||||
reset: reset,
|
||||
temperature: temperature,
|
||||
humidity: humidity,
|
||||
latLng: latLng,
|
||||
hdop: hdop,
|
||||
bitmap: bitmap,
|
||||
version: version,
|
||||
decode: decode
|
||||
};
|
||||
}
|
@ -25,6 +25,9 @@ function Decoder(bytes, port) {
|
||||
decoded.uptime = ((bytes[i++] << 56) | (bytes[i++] << 48) | (bytes[i++] << 40) | (bytes[i++] << 32) |
|
||||
(bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.temp = bytes[i++];
|
||||
decoded.memory = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.reset0 = bytes[i++];
|
||||
decoded.reset1 = bytes[i++];
|
||||
}
|
||||
|
||||
if (port === 5) {
|
||||
|
Loading…
Reference in New Issue
Block a user