08-27-2019 07:25
08-27-2019 07:25
Hello!
I am trying to create a client-local server connection between my Fitbit Versa and my local machine, using hard-defined websocket IP addresses. Ultimately, I am trying to stream my real-time heart rate as a console message to my local machine, where my server can handle that data accordingly.
Here is a paste of my code in question: https://pastebin.com/yp64REdT
I am getting this error when I Run my code onto my Versa:
I am brand new to JS, much less Fitbit development, so if this is simple, feel free to rip me open for not knowing lol... but do you guys have any clue for how to get this code running smoothly?
Thank you!
Answered! Go to the Best Answer.
08-27-2019 13:35
08-27-2019 13:35
I don't think WebSockets are available on the watch itself. You have to use file transfer or messaging to get data from watch to companion; then you can use WebSockets on the companion.
08-27-2019 07:29
08-27-2019 07:29
Hey guys... use this PasteBin link instead, this is the actual code that flags the error. I was toying around with the import function to see if that had anything to do with it.
08-27-2019 13:35
08-27-2019 13:35
I don't think WebSockets are available on the watch itself. You have to use file transfer or messaging to get data from watch to companion; then you can use WebSockets on the companion.
08-28-2019 08:30 - edited 08-28-2019 08:31
08-28-2019 08:30 - edited 08-28-2019 08:31
I found it impossible to get Socket.io running on the companion app, as the companion only offers the native WS API. This means you'll have to build your own WS transport and essentially reengineer Socket.io.
If anyone else has managed to connect to a server running Socket.io, please let me know. We're currently polling periodically with HTTP but we consider this a very inelegant solution.
08-28-2019 08:33
08-28-2019 08:33
Thank you for your responses, my next question is, when implementing WS using the Fitbit Companion Websocket API, can we use ws connections, or are we limited to only using wss?
If I could use ws, then I could use a simple Python local webserver to connect to the companion program on the same WiFi network.
Has anyone had any luck with this?
Thanks!