Last active
April 26, 2023 15:07
Star
You must be signed in to star a gist
exampleDecoder.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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