data = [ 0x01, // packet type and subtype
0xf0,0x05,0x05,0x05, // heatingEnergy
0x00,0x05,0x05,0x05, // coollingEnergy
0x05,0x05,0x05,0x05, //volume
0xf3,0x17,0x03, // averageReturnTemperature + maxReturnTemperature
0x0f]; // debug
input = { fPort:1, bytes:data };
var result = decodeUplink(input);
console.log(result);
// Copy this to Chirpstack
function decodeUplink(input) {
var decoded = {};
if (input.fPort == 1 ){ // you can ommit this if the fPort is always 1
decoded.type = input.bytes[0] & 0x0f;
decoded.subtype = input.bytes[0] & 0xf0;
decoded.heatingEnergy = input.bytes[1] << 24 | input.bytes[2] << 16 | input.bytes[3] << 8 | input.bytes[4];
decoded.coollingEnergy = input.bytes[5] << 24 | input.bytes[6] << 16 | input.bytes[7] << 8 | input.bytes[8];
decoded.volume = input.bytes[9] << 24 | input.bytes[10] << 16 | input.bytes[11] << 8 | input.bytes[12];
decoded.averageReturnTemperature = input.bytes[13] << 8 | input.bytes[14] & 0x0f;
if ( ( input.bytes[13] & 0x80 ) == 0x80) {
decoded.averageReturnTemperature *= -1;
}
// I don't know where is the half byte. I suppose upper bits of bytes[14]
decoded.maxReturnTemperature = (input.bytes[14] & 0xF0 ) << 8 | input.bytes[15];
if ( ( input.bytes[14] & 0x8 ) == 0x8) {
decoded.maxReturnTemperature *= -1;
}
decoded.bytes = input.bytes.length;
}
return decoded;
}// function Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json.
Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.
Google chrome's javascript engine V8 and is pretty fast.Asynchronous, event-driven and works on single-thread model thus eliminating the dis-advantages of multi-thread model.Express is one of the most popular web application framework in the NodeJS echosystem.
let moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
const _ = require("lodash");
let colors = ['blue', 'green', 'yellow', 'red'];
let firstElement = _.first(colors);
let lastElement = _.last(colors);
console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);
Following are the libraries supported by OneCompiler's NodeJS compiler.