08-04-2019 01:02
08-04-2019 01:02
Hi,
I made sideload app for collecting accelerometer data, and I checked sending data to compaion through messenger API.
Now, I want to send my data to local mysql database in my macbook.
I found 'fetch api' that can post data to the web in documents.
Can I use this api for sending my data from companion to mysql database?
I would like to hear advice if you have experience with it.
Answered! Go to the Best Answer.
08-05-2019 22:59
08-05-2019 22:59
If you are using your local IP address in your fetch API on the companion then when you go off your local wifi, this local IP address is no longer available which will prevent the transfer. In the case of your phone being connected to a different internet network such as 4G you would need to access your servers external IP address which will be completely different. The issue with this method is that due to it now being considered an external IP address you need to self certify that server and connect via https.
08-05-2019 06:36
08-05-2019 06:36
Firstly, Messenger API can be unreliable. My recommendation is to store the data on the watch and once you are done transfer using the file transfer API.
Fetch is the only way to get data from the fitbit off your phone (companion). You will need to host a server that can handle your fetch APIs . If its local, http works, if its not you need to self certify the server to get https.
Once your server can handle the requests then its just a matter of syncing your database to the server so the server can write the data it receives to the database.
08-05-2019 20:50
08-05-2019 20:50
Thank you for your reply!
I succeeded in sending data to the web server via the fetch api.
But, Now I have a another issue!
I noticed that only when the companion and my MacBook installed the web server were connected to the same WiFi, the data transmission was done.
Not surprisingly, stopping the Wi-Fi connection on the phone(companion) stopped the data transfer.
I would like to advise you on how to make phone(companion) send data to a web server without being connected to Wi-Fi.
08-05-2019 22:59
08-05-2019 22:59
If you are using your local IP address in your fetch API on the companion then when you go off your local wifi, this local IP address is no longer available which will prevent the transfer. In the case of your phone being connected to a different internet network such as 4G you would need to access your servers external IP address which will be completely different. The issue with this method is that due to it now being considered an external IP address you need to self certify that server and connect via https.
08-07-2019 19:10
08-07-2019 19:10
Thank you for your reply!
I solved my problem!