Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wisnode button 4k V2 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions vendors/rakwireless/devices/wisnode button 4k V2
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Payload Decoder for ChirpStack v4
*
* @author Pixeldieb
* converted from a TTN decoder, variable for button message can be set according to your application
*/

function decodeUplink(input) {
var bytes = input.bytes;
var pressed_button;

// Map byte values to button numbers
switch (bytes[0]) {
case 49:
pressed_button = "1";
break;
case 50:
pressed_button = "2";
break;
case 51:
pressed_button = "3";
break;
case 52:
pressed_button = "4";
break;
default:
pressed_button = "Unknown button value";
break;
}

// Return the decoded result in ChirpStack v4 format
return {
data: {
button_pressed: pressed_button
},
warnings: [],
errors: []
};
}