Skip to content

Commit

Permalink
Simplify data checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JovannMC committed Apr 21, 2024
1 parent 8c7c7c1 commit 9b92362
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/devices/haritorax-wireless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1083,12 +1083,6 @@ function processIMUData(data: string, trackerName: string) {
haritora.emit("connect", trackerName);
}

// Check if the data is valid
if (!data || data.length < 14) {
error(`Invalid IMU packet for tracker ${trackerName}: ${data}`);
return false;
}

// Decode and log the data
try {
const { rotation, gravity, ankle, magStatus } = decodeIMUPacket(
Expand Down Expand Up @@ -1153,10 +1147,7 @@ function decodeIMUPacket(data: string, trackerName: string) {
const gravityRawY = buffer.readInt16LE(10);
const gravityRawZ = buffer.readInt16LE(12);

let ankle = undefined;
if (data.slice(-2) !== "==" && data.length > 14) {
ankle = buffer.readInt16LE(buffer.length - 2);
}
let ankle = data.slice(-2) !== "==" ? buffer.readInt16LE(buffer.length - 2) : undefined;

let magStatus = undefined;
if (!trackerName.startsWith("HaritoraX")) {
Expand Down

0 comments on commit 9b92362

Please sign in to comment.