Skip to content

Commit

Permalink
Remove tracker inactivity
Browse files Browse the repository at this point in the history
gonna let people handle this instead, just in case this isnt desired (aka im having issues with something as simple as this lol)
  • Loading branch information
JovannMC committed Aug 13, 2024
1 parent bf03e1e commit 189c4ee
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/HaritoraX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,6 @@ export default class HaritoraX extends EventEmitter {
bluetoothEnabled = false;
}

for (let [key, trackerTimeout] of Object.entries(trackerTimeouts)) {
if (removedDevices.includes(key)) {
clearTimeout(trackerTimeout);
delete trackerTimeouts[key];
}
}

canSendButtonData = false;
}

Expand Down Expand Up @@ -855,18 +848,7 @@ export default class HaritoraX extends EventEmitter {
}
}

const trackerTimeouts: { [key: string]: NodeJS.Timeout } = {};
function listenToDeviceEvents() {
const resetTrackerTimeout = (trackerName: string) => {
if (trackerTimeouts[trackerName]) {
clearTimeout(trackerTimeouts[trackerName]);
}
trackerTimeouts[trackerName] = setTimeout(() => {
main.emit("disconnect", trackerName);
log(`Tracker ${trackerName} assumed disconnected due to inactivity.`);
}, 5000);
};

/*
* COM events
*/
Expand All @@ -875,8 +857,6 @@ function listenToDeviceEvents() {
com.on("data", (trackerName: string, port: string, _portId: string, identifier: string, portData: string) => {
if (!canProcessComData) return;

if (activeDevices.includes(trackerName)) resetTrackerTimeout(trackerName);

if (trackerModelEnabled === "wireless") {
switch (identifier[0]) {
case "x":
Expand Down Expand Up @@ -966,8 +946,6 @@ function listenToDeviceEvents() {
bluetooth.on("data", (localName: string, service: string, characteristic: string, data: string) => {
if (!canProcessBluetoothData || service === "Device Information") return;

if (activeDevices.includes(localName)) resetTrackerTimeout(localName);

switch (characteristic) {
case "Sensor":
processIMUData(Buffer.from(data, "base64"), localName);
Expand Down Expand Up @@ -1009,7 +987,6 @@ function listenToDeviceEvents() {

bluetooth.on("disconnect", (peripheral) => {
const trackerName = peripheral.advertisement.localName;
delete trackerTimeouts[trackerName];
main.emit("disconnect", trackerName);
});

Expand Down

0 comments on commit 189c4ee

Please sign in to comment.