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

Initial connection to companion when installing clockface

ANSWERED

Hello,

I've got a clockface that I'm developing that uses the companion to connect to some web services, collate data from the various services into a json formatted file to be sent to the fitbit Versa for display.  Works great except when I initialize the clockface after I run it from dev studio.  The clockface displays but none of the companion data displays until I get out of the clockface and then back in... say if I go to the "today" screen, and then back into the clockface, then it communicates with companion and all the data appears from then on out.

 

How can I make it so the clockface communicates with the companion right off the bat without me having to go out by closing it and then back in?

Thanks.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I am assuming that your code includes a function to read and display all the data. You could call this function when you receive the file on the device, unless I am missing something.

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Just stumbling in the dark here but it sounds like the data is retrieved, formatted and sent to the device AFTER it finishes displaying. Pepper your code with some 

console.log( "checkpoint ..." );

in order to test this hypothesis and understand what really happens during the first run.

Best Answer
0 Votes

Correct.  Upon first install/run after building in the dev studio, the clockface displays prior to initially fetching any data from the companion.   So, certain elements like the time, heart, steps, etc... display but the data, such as weather, from the companion don't display. I use the file transfer process for interacting with the companion.  The thing is, that file interaction doesn't automatically take place when I build and run the clockface.  I have to wait for it to install and display... with many of the data elements on the display remaining blank... then I have to either go to some other app or the "today" screen or settings, then back to the clockface... then the clockface will open the file, read the data and display the data on the clockface.  From then on out, it works properly and fetches data from the file created on the companion properly.. until I build and install another version from dev studio.

Best Answer
0 Votes

I am assuming that your code includes a function to read and display all the data. You could call this function when you receive the file on the device, unless I am missing something.

Best Answer
0 Votes

Oh man, big time goof on my part.  I didn't put that function in my init area... thought I had.  Added it and now runs fully  with no issues start to finish.  

 

Best Answer