08-27-2018 19:53
08-27-2018 19:53
I want to :
- Log some data using my watch face (I'm trying to quantify battery usage rate over time)
- Write the log to the watch's filesystem to collect data over days and weeks
- Access the resulting log file from my desktop PC with a spreadsheet program
I find a lot of scattered info in the API that might be useful, but not any single comprehensive outline of the necessary steps. I suspect it might be necessary to:
- Use the FileSystem (FS) API's "openSync" call to create a text file
- Use the "writeSync" call to append data to the file
- Close the file using "closeSync"
- Create a companion app
- Use the Messaging API to transfer the file to the companion (on demand, perhaps? or scheduled?)
- and then...???
That's where my research chain breaks down. I've seen some hints (in various community forum posts) that it's necessary to use the Companion's local storage but I can't find any details of how to do that, nor can I find any information on how to access that local storage so that I can export the data off my phone ("mobile device"). I also see some hints about pinging a website with the data, meaning perhaps I need to set up a web script to accept and process the file?
My preference would be to simply dump the text file into USB-accessible storage on my phone, if that's possible.
If anyone has a more thorough step-by-step, I'd appreciate any tips.
08-27-2018 20:47
08-27-2018 20:47
Unfortunately, it's probably even harder than that. The messaging API doesn't handle file transfers per se, and the file-transfer API only transfers from companion to device rather than vice versa. Ergo, you may want to transfer readings using the messaging API piecemeal, rather than batched into a file.
The companion doesn't provide an easy way to make data available elsewhere. You probably need to use fetch() or something to transfer the data to a web server. If you're really good, you could perhaps write your own web server to run on your companion device.
08-28-2018 14:14
08-28-2018 14:14
Using the messaging API for moment-by-moment transfers is an option, yes, but it's only a partial and undesirable solution.
First, it still doesn't solve the problem of extracting the data to a fixed location where I can analyze it (unless I try to ping a webserver with every single data point).
Second, and more importantly, I need to log data whether or not the phone is nearby. Basically, what I want for this app is to record battery level every time the screen wakes up (should be sufficient to gather what I want, and minimizes the battery usage compared to a timed recording). But if it only works when the phone is nearby, that eliminates a lot of potential data - like while I'm playing soccer and the phone is a hundred yards away.
I have plenty of web skills and could easily set up a simple PHP script on one of my various websites, that accepted a simple JSON message and logged the data. But I expect to be collecting hundreds of data points per day, and pinging the server every time (even through the phone) will certainly corrupt the exact thing I'm trying to measure - battery life.
Okay, I could log the data when the companion isn't responding, and then batch submit it. But again, battery drain becomes an issue, and the API also says that messaging has very strict and rather small message limits (1024 bytes, practically).
So all in all, I'd much rather have access to a simple downloadable text file at the end of my experiment.
I should note that what I'm trying to do would also benefit other possible applications - such as sleep logging. Yes, those things can be accomplished with some kind of a sync protocol - but it puts a high burden on external interfaces (web servers etc.).
So I guess if there's not any way to do this right now, I would want to suggest a (hopefully minor) API tweak to allow the Fitbit phone app to export files to the phone's data storage.
08-28-2018 20:49
08-28-2018 20:49
No argument; I was only suggesting ugly workarounds given the limitations of the status quo.
In addition to your final suggestion, you might also want to suggest that the file transfer API allow watch-to-companion transfers.
There's a suggestion topic here.