-
Notifications
You must be signed in to change notification settings - Fork 1
Setup [Legacy v1.3.0]
This guide is for legacy versions of FitbitHRtoWS (v1.3.0 and below). Please see the new guide for Version 1.4.0 and above!
This section is split into two parts. Part 1 is for setting up the Websocket and Part 2 for setting up the app.
- Node.JS
- npm
Getting the Program
Download and Extract the Latest Release from the Releases Page.
WebViewer Setup This step is optional if you don't want the WebPage View to work on other clients connecting outside your machine or globally.
Navigate into the /ws/html
folder in the file you just extracted, and edit it with any editor (I recommend VS Code or Notepad++). Scroll to the only <script>
tag in the file and change the line that says something along the lines of:
...
var socket = new WebSocket("ws://localhost:8080/")
...
to what your socket address will be.
My Websocket will run on 192.168.1.107
and the Port for the Socket will be 4567
...
var socket = new WebSocket("ws://192.168.1.107:4567/")
...
Installing npm's
Open CMD (I prefer to use Cmder) and navigate to your /ws
folder. Next, install all the npm's required.
npm i express
npm i http
npm i ws
Websocket Setup This step is optional if you want to run the server on the default IP and Ports
Navigate to your /ws
folder. Open ws.js
in with any text editor (I recommend VS Code or Notepad++).
The password
const is a password for the Fitbit to use to connect, and verify that the socket that is sending all the info is actually the fitbit sending it, not an imposter! (sus!😳)
"WAIT, IF YOU'RE SENDING THE PASSWORD OVER AN INSECURE WS, CAN'T SOMEONE JUST MITM ATTACK THE SOCKET????!?!?!??!?!?!??!"
Yes, which is why you do one of the following:
- Don't open the Port to the Public
- Secure the Websocket with WSS
- (I wouldn't recommend, but might work) Proxy the Websocket with Cloudflare [Might require the WS to run on Port 80]
If you're running the Websocket on your local machine, and you're NOT opening ports to the public, then no worries, you can just leave this at CHANGEME.
Look for the following lines of code, probably near the top.
http.listen(8000, () => {
console.log('http server listening on *:8000');
});
In the code above, 8000
would be the Port the WebViewer runs on.
Look for the following line of code, probably below the WebViewer Port stuff (see above).
var wss = new WebSocket.Server({ port: 8080 })
In the code above, 8080
would be the Port the Socket runs on.
Running the Websocket!
Open CMD (I prefer to use Cmder) and navigate to your /ws
folder.
Run the following command
node ws.js
If installed correctly, you will see a line saying:
http server listening on *:8000
(Note: As of 2/1/2021
, the server will return 8000
as the port no matter what)
- Node.JS
- npm
- npx
- @fitbit/[email protected] (Other SDK Versions will work if you're porting on a different device)
- @fitbit/sdk-cli (Any version of the CLI is fine as long as it's compatible with your SDK version)
Getting the App
Download and Extract the Latest Release from the Releases Page.
Creating your app!
Open CMD (I prefer to use Cmder) and navigate to the file you just extracted.
Run the following command:
npx create-fitbit-app [directory to store app]
Note: The Directory IS Caps Sensitive.
EX: fitbitapp
would be stored in [Location where the Extracted Folder is]/fitbitapp
Now, wait for the CLI to ask you questions.
The questions
Fill in the following for these questions:
- Q: What type of application should be created? (Use arrow keys) A: app
- Q: What should the name of this application be? (My Watch Face) A: Input the name that you want to call the app
- Q: Should this application contain a companion component? (Y/n) A: n
- Q: Which platforms should this application be built for? (Press to select, to toggle all, to invert selection) A: a (or you can select your device)
Preparing the app for building
Copy all folders from /app/sdk[target sdk version]/
and paste them into the app you created's directory (see Step 2).
WARNING: DO NOT COPY package.json
YET!
Setting up package.json
Navigate into the directory where you just copied all those folders. Open package.json
file in any text editor (I recommend VS Code or Notepad++).
IMPORTANT: Be sure to save/copy the app's UUID before completing this step! (You will need it here in a second ;) )
Copy the file from /app/sdk[target sdk version]/package.json
and paste it into the app you created's directory, and overwrite. Open that file, and set the appUUID
to the one you just saved.
Preparing for sideloading!
Open CMD (I prefer to use Cmder) and navigate into the app you created's directory, and run the following command:
npx fitbit
Then, you should be redirected to sign-in to Fitbit developers.
After signing in, you should see $fitbit
on he terminal line, if not, then restart the terminal window, and run the command again.
Note: Make sure your phone is connected to the same Network your Server is on (if you're connecting locally). Note: Your Fitbit must be connected to your app over bluetooth.
In the Fitbit app, go to your Today
tab, select your Profile Image in the top left, select the device you'll be sideloading to, go to the Developer Menu, and turn on Developer Bridge
.
Back to the terminal!
Run the command connect phone
and your phone should connect to the CLI.
Note: This may take a couple of tries, keep retrying the command a couple times if it doesn't work the first.
IMPORTANT: When the watch is connect to the Debugger, its battery life will decrease significantly . It should only be used to Sideload the app.
On your watch, navigate to settings, then scroll until you see Connect to Debugger
, hit that. Once you're connected to the debugger, run the following command in the terminal:
connect device
Note: This may take a couple of tries, keep retrying the command a couple times if it doesn't work the first.
Building and Sideloading!
In the terminal window, run the following command to build the app:
build
Then, run the following command to sideload/install the app to the connected device/watch:
install
In your Fitbit app, navigate to your Developer Menu again (see Step 6), and under Sideloaded Apps
, select the app name you created back in Step 2. Hit Settings in the list.
Replace WS Uri
with your Webcoket Address.
Replace Server Password
with the password for your Websocket.
Set Low Interval Update
to on or off. On will update HR at 0.5sec/500ms; Off will update HR at 1sec/1000ms.