Skip to content

Instantly share code, notes, and snippets.

@RandomGenericUsername
Last active April 26, 2023 15:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save RandomGenericUsername/ed777da3346928fcdbc8ff7bb8daf922 to your computer and use it in GitHub Desktop.
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"};
}
temperature = bytes[1] << 8 | bytes[2];
humidity = bytes[3] << 8 | bytes[4];
return {"temperature" : temperature, "humidity" : humidity};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment