Hello,
I wanted to use the Fetch API to transfer the accelerameter data to an android phone by using this code
https://github.com/gondwanasoft/fitbit-accel-fetcher
However, It doesn't run on my computer and based on the error it says fetch() couldn't send request to server. I used a local host and this IP 127.0.0.1 does anyone know how can I fix that?
Best,
Answered! Go to the Best Answer.
Best AnswerHeaps more. It's described in the readme. Without a server, the URL won't know what to do with the data.
Best AnswerI connected both laptop and phone to the personal wifi and just built the application on my watch and companion on phone and didn't run any server on my phone. Do I need to do anything else in other to be able to send data to the mentioned URL?
Best AnswerHeaps more. It's described in the readme. Without a server, the URL won't know what to do with the data.
Best AnswerThank you for the help. I'll check it out again. Can I directly send the data of accelerometer to a web service such as drop box? Is it just as easy as sending it to the phone?
Best AnswerI think drop box (etc) will require a very specific protocol, including heaps of authentication. I think there is a web site that can catch and save simple files sent to it, but I don't know its URL.
Best AnswerI checked the readme, and I don't know if I run the server correctly or nor, I used Fitbit studio and run the application on the phone and used the android studio and run the android-fitbit-fetcher on the same phone. while both are running on my phone when I send the transfer data button it gives me the error that I mentioned.
Best AnswerExactly what error message was displayed, and where was it displayed? What URL did you use for fetch?
Unfortunately there are about a billion things that can go wrong.
Best AnswerThe error is "server not found on 1" and the URL that I used is URL = http://127.0.0.1:3000
Best AnswerI don't think my code is capable of displaying that, so it may be coming directly from the API. The 'on 1' is strange; maybe check IP formatting.
It would still be helpful to know where you see this message.
There may be other clues in the console output.
I assume the Android app was running on your phone.
Best AnswerAmend that: I can see where the message is coming from...
Best AnswerThe error massage is shown on watch, and the android app was running on the phone but the number of received file is always zero.
Best AnswerAh. The key thing there is the TypeError. That's coming from the API and simply means that the fetch() didn't work. It can happen from incorrect IP, including incorrect security.
Unfortunately, Fitbit broke fetch() to http recently (see here). If they haven't fixed it yet, that's the error you'd get. I don't know if they've fixed it.
Best AnswerThank you for your help. It means that I need to use https to solve the issue? do I need to address the same URL but type https instead pf http?
Best AnswerThat would only work if there's a non-self-signed certificate installed on the server (Android app). I'd have no idea how to do that. It's probably possible but difficult.
It used to be possible to host a server for free (with https included) on heroku, but I think they've got rid of the free tier. There may be other equivalent services. To use them, you'd need a server written in something like php or node.js.
Best AnswerFor what it's worth, I just fired up fitbit-accel-fetcher and android-fitbit-fetcher, and it worked fine. This indicates that Fitbit has fixed the issue that was preventing the use of local unsecured connections.
Best AnswerThank you for the update. I fired up both applications again but I received the same error on watch "Server not found on 1" and status 1 is server didn't respond to fetch() request. Do I need to update the Fitbit software to fix it? In order to clarify what I did, I kept the android-fitbit-fetcher open and the run the Fitbit-accel-fetcher and started to record data and then pushed the transfer button and then the error was displayed. On phone the "GET DATA" button is always disable since the number of received files is zero.
Regards,
Best AnswerI think the key message that you reported before was 'TypeError: Failed to fetch'. As I understand it, that means that the companion is not even able to send the fetch request, so nothing gets as far as the server.
My Fitbit mobile app is version 3.66 (36669011). Make sure the IP address that fetch is using is allowed, and that you've given the app internet permission.
Best AnswerThank you again for your help. I am reading the code to better understand what happened. Could you please let me know what is the goal of the function simAccelTick(), you commented fake data for it. Since we read accelerometer data what is the need of this function!!!
Best AnswerFrom memory, simAccelTick should only be called if the app is running in the Fitbit simulator (investigate the variable isSim). When used on a real watch, simAccelTick won't be used; actual sensor data will be used instead. In a production build, sim-specific code should be removed.
Best Answer