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

Extended payload formatter for new features #842

Merged
merged 2 commits into from
Nov 14, 2024
Merged
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
84 changes: 83 additions & 1 deletion vendor/plenom/busylight.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,68 @@ function decodeUplink(input) {
errors: []
};
}
else if (input.bytes.length == 25)
{
switch (input.bytes[24])
{
case 0x01:
reason="Power On Reset";
break;
case 0x02:
reason="Brownout 1.2V";
break;
case 0x04:
reason="Brownout 3.3V";
break;
case 0x10:
reason="External Reset";
break;
case 0x20:
reason="WatchDog Timer triggered";
break;
case 0x40:
reason="Software";
break;
case 0x80:
reason="Backup";
break;
}
return {
data: {
RSSI: byteArrayToLong(input.bytes, 0),
SNR: byteArrayToLong(input.bytes, 4),
messages_received: byteArrayToLong(input.bytes, 8),
messages_send: byteArrayToLong(input.bytes, 12),
lastcolor_red: input.bytes[16],
lastcolor_blue: input.bytes[17],
lastcolor_green: input.bytes[18],
lastcolor_ontime: input.bytes[19],
lastcolor_offtime: input.bytes[20],
sw_rev: input.bytes[21],
hw_rev: input.bytes[22],
adr_state: input.bytes[23],
last_reset_reason: reason
},
warnings: [],
errors: []
};
}
else if (input.bytes.length == 10)
{
return {
data: {
messages_send: byteArrayToLong(input.bytes, 0),
lastcolor_red: input.bytes[4],
lastcolor_blue: input.bytes[5],
lastcolor_green: input.bytes[6],
lastcolor_ontime: input.bytes[7],
lastcolor_offtime: input.bytes[8],
last_reset_reason: input.bytes[9]
},
warnings: [],
errors: []
};
}
else
{
return {data: {
Expand Down Expand Up @@ -48,8 +110,10 @@ function encodeDownlink(input) {
}

function decodeDownlink(input) {

if (input.bytes.length == 5)
{
return {

data: {
red: input.bytes[0],
green: input.bytes[2],
Expand All @@ -60,4 +124,22 @@ function decodeDownlink(input) {
warnings: [],
errors: []
}
}
else if (input.bytes.length == 6)
{
return {

data: {
red: input.bytes[0],
green: input.bytes[2],
blue: input.bytes[1],
ontime: input.bytes[3],
offtime: input.bytes[4],
immediate_uplink: input.byte[5]
},
warnings: [],
errors: []
}
}
}

Loading