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

JSON Retrieved and Processed in Fitbit Simulator - Doesn't work on watch

I have code that uses file-transfer at the beginning of its launch to retrieve a JSON from my server. The JSON is retrieved instantly when I use the Fitbit Simulator, but takes ~5-30 seconds while running on an actual Fitbit Iconic. The JSON is ~500 characters long.

 

I'm pretty sure that the retrieval process is working and I believe that file should be on the watch - Looking at my console:

[8:54:20 PM]Transfer of 'habits.json' successfully queued.

[8:54:25 PM]/private/data/habits.json is now available

 

App's code:

 

// Event occurs when new file(s) are received
inbox.onnewfile = function () {
  var fileName;
  do {
    // If there is a file, move it from staging into the application folder
    fileName = inbox.nextFile();
    if (fileName) {
      console.log("/private/data/" + fileName + " is now available");
    }
  } while (fileName);
};

 

When I try to read the JSON while using my actual ionic watch I get the following error:

[8:54:30 PM]Unhandled SyntaxError: JSON string parse error.

 

When I use the Fitbit Simulator the code works flawlessly.

 

I'm receiving the error on the first line below:

let text = readFileSync("/private/data/habits.json", "json");
console.log(text);
habitsJSON = text;
VTList.length = habitsJSON.length;

Am I missing something? Is this a bug in the ionic watch that doesn't exist within the Simulator?

 

My Firmware version is: 27.32.10.15 and it doesn't saw that I need to update.

 

One additional error I seem to be getting at the start of the app on both the Simulator and Watch: [8:53:54 PM]Error 22 Invalid value 'Start'

 

Thank you,

-Don

Best Answer
0 Votes
4 REPLIES 4

Do you have a project export that reproduces this issue, or a copy of the JSON content? Does it work if you use the CBOR encoding?

Best Answer

Thanks for the response and sorry for my delay.

 

I have not tried CBOR encoding, but the JSONs are really small in size, so I'm not sure what CBOR will buy me?

 

I placed the repository on gitHub: https://github.com/RocketMan1988/HabitTracker.

 

-Don

 

 

 

Best Answer
0 Votes

Any news on this. Ran into the same issue: Parse is working on simulator, but not on Ionic.

Best Answer
0 Votes

Can you post the JSON?

Best Answer
0 Votes