Created
January 31, 2017 18:13
-
-
Save proffalken/c9d7125038dfc283a9d3fafbcbeed427 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Decoder(bytes, port) { | |
// Decode an uplink message from a buffer | |
// (array) of bytes to an object of fields. | |
var decoded = {}; | |
if (port === 10) { | |
decoded.pm25count = parseFloat((bytes[1] << 8) + "." + bytes[2]); | |
decoded.pm10count = parseFloat((bytes[3] << 8) + "." + bytes[4]); | |
} | |
return decoded; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment