Created
October 1, 2024 09:13
-
-
Save PaulGoldschmidt/245186b30af25ec4ab6daa7eb86f415f to your computer and use it in GitHub Desktop.
Sample Decoding Function / payload formatter for the Heidelberg Buergerportal
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 decodeUplink(input) { | |
var temp = input.bytes[0] << 24 | input.bytes[1] << 16 | input.bytes[2] << 8 | input.bytes[3]; | |
var hum = input.bytes[4] << 24 | input.bytes[5] << 16 | input.bytes[6] << 8 | input.bytes[7]; | |
var pressure = input.bytes[8] << 24 | input.bytes[9] << 16 | input.bytes[10] << 8 | input.bytes[11]; | |
var gas = input.bytes[12] << 24 | input.bytes[13] << 16 | input.bytes[14] << 8 | input.bytes[15]; | |
return { | |
data: { | |
temperature: temp / 100, | |
humidity: hum / 1000, | |
pressure: pressure / 100, | |
gasResistance: gas / 1000 | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment