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

Implementing WebSockets to Communicate between Fitbit Versa and Local Server!

ANSWERED

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: Error Code when Building Posted Code onto Fitbit 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!

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

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.

 

https://pastebin.com/J8uTyHNP

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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.

Best Answer

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!

Best Answer