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

Adding different port variable name #86

Merged
merged 1 commit into from
Oct 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
28 changes: 5 additions & 23 deletions decoders/connector/dragino/cs01lb/v1.0.0/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ function getMyDate(str: string) {
const c_Hour = c_Date.getHours();
const c_Min = c_Date.getMinutes();
const c_Sen = c_Date.getSeconds();
const c_Time = `${c_Year}-${getzf(c_Month)}-${getzf(c_Day)} ${getzf(
c_Hour
)}:${getzf(c_Min)}:${getzf(c_Sen)}`;
const c_Time = `${c_Year}-${getzf(c_Month)}-${getzf(c_Day)} ${getzf(c_Hour)}:${getzf(c_Min)}:${getzf(c_Sen)}`;

return c_Time;
}
Expand All @@ -66,14 +64,7 @@ function datalog(i: number, bytes: Buffer) {
const cc = parseFloat(((bytes[5 + i] << 8) | bytes[6 + i]) / 100).toFixed(2);
const dd = bytes[0 + i] & 0x02 ? "High" : "Low";
const ee = bytes[0 + i] & 0x01 ? "True" : "FALSE";
const ff = getMyDate(
(
(bytes[7 + i] << 24) |
(bytes[8 + i] << 16) |
(bytes[9 + i] << 8) |
bytes[10 + i]
).toString(10)
);
const ff = getMyDate(((bytes[7 + i] << 24) | (bytes[8 + i] << 16) | (bytes[9 + i] << 8) | bytes[10 + i]).toString(10));
let string = `[${aa},${bb},${cc},${ff},${dd},${ee}]`;
string = string.concat(",");

Expand Down Expand Up @@ -167,9 +158,7 @@ function Decoder(bytes: Buffer, port: number) {
else if (bytes[3] === 0x0d) freq_band = "KR920";
else if (bytes[3] === 0x0e) freq_band = "MA869";

const firm_ver = `${bytes[1] & 0x0f}.${(bytes[2] >> 4) & 0x0f}.${
bytes[2] & 0x0f
}`;
const firm_ver = `${bytes[1] & 0x0f}.${(bytes[2] >> 4) & 0x0f}.${bytes[2] & 0x0f}`;
const bat = ((bytes[5] << 8) | bytes[6]) / 1000;

return {
Expand All @@ -182,16 +171,9 @@ function Decoder(bytes: Buffer, port: number) {
}
}

const cs01lb_payload = payload.find(
(x) =>
x.variable === "payload_raw" ||
x.variable === "payload" ||
x.variable === "data"
);
const cs01lb_payload = payload.find((x) => x.variable === "payload_raw" || x.variable === "payload" || x.variable === "data");

const port = payload.find(
(x) => x.variable === "port" || x.variable === "fport"
);
const port = payload.find((x) => x.variable === "port" || x.variable === "fport" || x.variable === "fPort");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only modification was here.


if (cs01lb_payload) {
try {
Expand Down