09-02-2022 13:37
09-02-2022 13:37
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.
09-02-2022 13:56
09-02-2022 13:56
Heaps more. It's described in the readme. Without a server, the URL won't know what to do with the data.
09-02-2022 13:42
09-02-2022 13:42
127.0.0.1 will be your phone, not your computer. What server are you running on your phone?
09-02-2022 13:52
09-02-2022 13:52
I 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?
09-02-2022 13:56
09-02-2022 13:56
Heaps more. It's described in the readme. Without a server, the URL won't know what to do with the data.
09-02-2022 14:00
09-02-2022 14:00
Thank 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?
09-02-2022 14:05
09-02-2022 14:05
I 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.
09-02-2022 14:07
09-02-2022 14:07
I 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.
09-02-2022 14:17
09-02-2022 14:17
Exactly 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.
09-02-2022 14:44
09-02-2022 14:44
The error is "server not found on 1" and the URL that I used is URL = http://127.0.0.1:3000
09-02-2022 14:54
09-02-2022 14:54
I 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.
09-02-2022 14:57
09-02-2022 14:57
Amend that: I can see where the message is coming from...
09-02-2022 15:06
09-02-2022 15:06
The error massage is shown on watch, and the android app was running on the phone but the number of received file is always zero.
09-02-2022 15:17
09-02-2022 15:17
Ah. 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.
09-02-2022 16:30
09-02-2022 16:30
Thank 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?
09-02-2022 18:21
09-02-2022 18:21
That 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.
09-06-2022 22:00
09-06-2022 22:00
For 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.
09-06-2022 23:28
09-06-2022 23:28
Thank 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,
09-07-2022 00:06
09-07-2022 00:06
I 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.
09-13-2022 11:08
09-13-2022 11:08
Thank 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!!!
09-13-2022 13:14
09-13-2022 13:14
From 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.