Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wake Up Interval Companion

ANSWERED

Hello,

 

Apologies if this is in other topic. I was looking around and couldn't find a solution for the issue I have. If there is other thread with information that can help me with the issue I'm about to explain, please let me know.

 

I want to wake up the companion app every a certain time, for debugging purposes I put 5 minutes.

 

This is the code:

import { me } from "companion";
const MINUTE = 1000 * 60; me.wakeInterval = 5 * MINUTE; console.log("Wake Interval " + JSON.stringify(me.launchReasons)); me.onwakeinterval = evt => { console.log("Inside onwakeinterval"); if (me.launchReasons.wokenUp) { // The companion started due to a periodic timer console.log("Started due to wake interval!"); ... } };

This a link to a printscreen of the logs: https://www.dropbox.com/s/y0kv9d0ov8dz3qg/IMG_1271.jpg?dl=0

 

What I noticed from the logs is:

  • I configured the wake up every 5 minutes, but most of the time is waking up every 10 minutes.
  • Even I have an a code in place to show some logs when the onwakeinterval event happens, I don't always see all the logs I should see.

 

My questions are:

  1. Why is the companion waking up almost every 10 minutes, if it is coded to do it every 5 minutes?
  2. Why if wake up always with the wokenUp = true, not always go inside the below code? 
    me.onwakeinterval = evt => {...};

 

Hope you can help me with these problems.

Thanks in advance.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

The wakeInterval is only guidance to the mobile runtime to wake the companion, as per https://dev.fitbit.com/build/guides/companion/#periodic-wake-interval

 

 

There are 2 states your companion needs to listen for:

1. onwakeinterval - this event fires when your companion is already running and the interval elapses.

2. the launchReason.wokenUp

 

import { me } from "companion";
const MINUTE = 1000 * 60; me.wakeInterval = 5 * MINUTE;
me.onwakeinterval = evt => { console.log("Companion was already awake - onwakeinterval"); }

if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
console.log("Started due to wake interval!");
}

 

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

The wakeInterval is only guidance to the mobile runtime to wake the companion, as per https://dev.fitbit.com/build/guides/companion/#periodic-wake-interval

 

 

There are 2 states your companion needs to listen for:

1. onwakeinterval - this event fires when your companion is already running and the interval elapses.

2. the launchReason.wokenUp

 

import { me } from "companion";
const MINUTE = 1000 * 60; me.wakeInterval = 5 * MINUTE;
me.onwakeinterval = evt => { console.log("Companion was already awake - onwakeinterval"); }

if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
console.log("Started due to wake interval!");
}

 

Best Answer
0 Votes