12-09-2017 17:58
12-09-2017 17:58
I am getting pretty frustrated with the unreliability of the companion. It basically is stopping me from developing (and using) clock faces and app.
Please find below my companion code. My app/watch faces simply read the file. Messaging was limited in buffer and same issue with it being unreliable.
I wake the companion every 30 minutes. I also ask to run the geolocation every 30 minutes.
Nothing works. File is only updated if I am connected to the studio and running the app from there. If I don't connect, I won't get updated data. Package.json permissions are in place (Connect to the internet, run in background, use geolocation).
Please advise.
import { outbox } from "file-transfer";
import { encode } from 'cbor';
import { geolocation } from "geolocation";
import { me } from "companion"
function geoLoc(){
geolocation.getCurrentPosition(locationSuccess, locationError);
};
function locationSuccess(position) {
var API_KEY = MY API KEY HERE HIDDEN FOR PRIVACY;
var myLat = position.coords.latitude;
var myLon = position.coords.longitude;
var ENDPOINT = "https://www.worldtides.info/api?datum=LAT&extremes&lat=" + myLat + "&lon=" + myLon +"&key=" + API_KEY;
getTide(ENDPOINT);
}
function locationError(error) {
console.log("Error: " + error.code,
"Message: " + error.message);
}
function getTide(ENDPOINT) {
// console.log(ENDPOINT)
fetch(ENDPOINT)
.then(function (response) {
response.json()
.then(function(data) {
// console.log(JSON.stringify(data));
sendFile(data);
});
})
.catch(function (err) {
console.log("Error fetching tide: " + err);
});
}
function sendFile(data) {
// console.log("Sending file...");
const myFileInfo = encode(data);
outbox.enqueue("tide.txt", myFileInfo)
}
geoLoc();
// Helper
const MILLISECONDS_PER_MINUTE = 1000 * 60
// Wake the Companion after 30 minutes
me.wakeInterval = 30 * MILLISECONDS_PER_MINUTE
if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
geoLoc();
console.log("Started due to wake interval!")
} else {
// Close the companion and wait to be awoken
me.yield()
}
//Run geolocation and tide data every 30 minutes
setInterval(geoLoc(), 30 * 1000 * 60);
05-18-2018 09:27
05-18-2018 09:27
Same here. Paid. Author claims Fitbit issue.nsent me link to this thread. Oddly every other appbsynchs fine. Photo app crashes about 50% of this me after clicking Connect. Apps shouldn't crash because of connectivity error, they should catch the error and provide anhimannunderstandble error message.
Best Answer05-18-2018 09:28
05-18-2018 09:28
Same here. Paid. Author claims Fitbit issue.nsent me link to this thread. Oddly every other app synchs fine. Photo app crashes about 50% of this me after clicking Connect. Apps shouldn't crash because of connectivity error, they should catch the error and provide a human understandble error message.
Best Answer05-18-2018 12:49
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
05-18-2018 12:49
I'm closing this thread which relates to an old bug with the beta sdk.
If you are a developer and still have issues with messaging, or file transfer, please create a new thread containing code samples, device/os details, and any logs.
Best Answer