Skip to content

Instantly share code, notes, and snippets.

@proffalken
Created January 31, 2017 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proffalken/c9d7125038dfc283a9d3fafbcbeed427 to your computer and use it in GitHub Desktop.
Save proffalken/c9d7125038dfc283a9d3fafbcbeed427 to your computer and use it in GitHub Desktop.
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