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

Send file from device hard drive to PC or phone

ANSWERED

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?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

View best answer in original post

Best Answer
8 REPLIES 8

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.

Best Answer

Interesting suggestion. Thanks. That would mean connecting with the Developer bridge. I like the idea it is simple and effective.

Best Answer

@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.

Peter McLennan
Gondwana Software
Best Answer

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.

Best Answer
0 Votes

@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
}

See console.log limitation

Author | ch, passion for improvement.

Best Answer

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.

Best Answer

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?

Best Answer
0 Votes

You can use console.log in companion .js and .jsx files with CLI.

Peter McLennan
Gondwana Software
Best Answer