07-07-2023 06:58
07-07-2023 06:58
I have created a Clockface that saves information into a file it creates onto the device drive itself using the fs API https://dev.fitbit.com/build/reference/device-api/fs/.
I would like to transfer this relatively large file from the device to a PC or an android smartphone; is there a way to do it, ideally without having to go through the "companion" app which is the official android fitbit app on the smartphone? Is it possibly by some means?
Answered! Go to the Best Answer.
07-07-2023 10:39
07-07-2023 10:39
Hi @francogrex - one way for a private clock face would be to trigger, on the watch, a process of reading the file and writing each record with line number to the console.
With the watch connected to the Terminal the contents would appear there which could be copy/pasted elsewhere.
For reasons of integrity check that all line numbers are listed.
There are other more complicated ways with a companion, including setting up your own web server.
Author | ch, passion for improvement.
07-07-2023 10:39
07-07-2023 10:39
Hi @francogrex - one way for a private clock face would be to trigger, on the watch, a process of reading the file and writing each record with line number to the console.
With the watch connected to the Terminal the contents would appear there which could be copy/pasted elsewhere.
For reasons of integrity check that all line numbers are listed.
There are other more complicated ways with a companion, including setting up your own web server.
Author | ch, passion for improvement.
07-07-2023 11:50
07-07-2023 11:50
Interesting suggestion. Thanks. That would mean connecting with the Developer bridge. I like the idea it is simple and effective.
07-07-2023 13:11
07-07-2023 13:11
@Guy_'s warning about checking that all lines get displayed in the console is wise. The dev bridge seems to be rate-limited and drops lines if it's flooded.
07-08-2023 04:38
07-08-2023 04:38
I tried it out, but I hit a road block related to the console.log. Having written the data into the file with fs.writeFileSync("myfile.txt", data, "utf-8") when the time came to use the console.log(fs.readFileSync("myfile.txt", "utf-8")), the data is indeed displayed on the PC screen, but truncated after about 240 characters! which is indeed a pity because this solution was so simple, but that snag is unfortunate. console.dir may have been better with a larger buffer/text length but it isn't a part of the Fitbit sdk sadly, so If anyone has a workaround I'm interested. Thanks.
07-08-2023 05:17
07-08-2023 05:17
@francogrex- yes there is a line limit issue. Replace "console.log" with a function, such as consolelog
function consolelog(message){
print message here in chunks of 100 characters so that you can reassemble them again
}
Author | ch, passion for improvement.
07-08-2023 06:38
07-08-2023 06:38
yes. after I asked the question an idea came to me to write to the file line by line (newline separated) and then reading line by line also from that file, printing each line read to the console. that worked out.
07-08-2023 09:45
07-08-2023 09:45
Using the console.log in the context of the developer bridge and the Fitbit cli is working as desired now (and thanks again for your help). How about similar communication between the device and a smartphone for example? on the phone there is no node.js / Fitbit studio cli, but would there still be a way to console.log on an android phone for example?
07-08-2023 13:19
07-08-2023 13:19
You can use console.log in companion .js and .jsx files with CLI.