Skip to content

Commit

Permalink
Update SDK and disable BT detection when fetching weather or asleep
Browse files Browse the repository at this point in the history
  • Loading branch information
lemnet committed Aug 3, 2021
1 parent d9a32af commit e0a4a26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 17 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { vibration } from 'haptics';
import { geolocation } from "geolocation";
import { battery } from 'power';
import { me as device } from "device";
import sleep from "sleep";
import * as messaging from "messaging";
import * as fs from "fs";

Expand Down Expand Up @@ -145,6 +146,10 @@ function processWeatherData(data) {
"location": data.location,
}
fs.writeFileSync("weather.txt", json_data, "json");
if (fs.existsSync("/private/data/bt.txt")) {
if (fs.readFileSync("bt.txt", "json") == "true")
btckeck = setInterval(checkBT, 30000);
}
// console.log(`The icon is: ${data.icon}`);
// console.log(`The temperature is: ${data.temperature}`);
// console.log(`The location is: ${data.location}`);
Expand Down Expand Up @@ -305,6 +310,7 @@ function checkBT() {
//update weather
function updateWeather() {
let currentDate = new Date();
clearInterval(btckeck);
setTimeout(function(){
if ((currentDate.getTime() - lastfetch) > 1799980) {
clearInterval(wu);
Expand All @@ -331,4 +337,15 @@ display.addEventListener("change", () => {
secDisplay = 0;
clock.granularity = "minutes";
}
});

sleep.addEventListener("change", () => {
if (sleep.state == "asleep")
clearInterval(btckeck);
else {
if (fs.existsSync("/private/data/bt.txt")) {
if (fs.readFileSync("bt.txt", "json") == "true")
btckeck = setInterval(checkBT, 30000);
}
}
});
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"devDependencies": {
"@fitbit/sdk": "~4.2.0"
"@fitbit/sdk": "~4.3.0"
},
"fitbit": {
"appUUID": "1c059981-f8af-4a7c-b8c0-d87c241f0068",
Expand All @@ -13,11 +13,12 @@
"access_heart_rate",
"access_location",
"access_internet",
"run_background"
"run_background",
"access_sleep"
],
"buildTargets": [
"meson",
"mira",
"meson",
"gemini"
],
"i18n": {
Expand Down

0 comments on commit e0a4a26

Please sign in to comment.