Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enqueueRequest();
return;
}
// We need to wake up the car
log('Waking vehicle...');
await Tesla.wakeUpAsync(options);
// When this request completes, the vehicle isn't already awoken. It's waking up.
// The official Tesla app then does the vehicle data request repeatedly until it works
}
let result = null;
for (let i = 1; i <= 20; i++) {
// Retry at most 20 times
try {
result = await Tesla.vehicleDataAsync(options);
break; // it worked
} catch (ex) {
log(`Error retrieving vehicle data on request ${i}: ${ex.message}`);
if (i == 20) {
throw ex; // this attempt failed
}
// Wait a second and try again
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
g_LastPoll = g_CarLastSeenAwake = Date.now();
g_DataListenerSockets.forEach((socket) => {