Skip to content

Instantly share code, notes, and snippets.

View RandomGenericUsername's full-sized avatar

Juan David Tangarife Hernandez RandomGenericUsername

View GitHub Profile
@RandomGenericUsername
RandomGenericUsername / exampleDecoder.js
Last active April 26, 2023 15:07
exampleDecoder.js
function myDecoder(args)
{
var bytes = args.bytes;
var port = args.port;
var startFlag = bytes[0];
var temperature;
var humidity;
if(startFlag != 0xAA)
{
return {"Error" : "invalid start flag"};
function XYZDeviceDecoder(args)
{
var bytes = args.bytes;
var port = args.fport;
var status = args.status;
var temperature = bytes[0] || bytes[1] << 8;
var humidity = bytes[2] || bytes[3] << 8;
//return {"temp" : 0, "humidity" : 1};
return {"temperature" : temperature, "humidity" : humidity, "raw" : bytes, "port" : port, "status" : {"value" : 1, "context" : status}};