djwasser / M3iPiZeroW

Translate Keiser M3i broadcasts into Bluetooth smart services useful for use with training software
MIT License
9 stars 4 forks source link

Installing instructions #3

Closed Lloydster2000 closed 3 years ago

Lloydster2000 commented 3 years ago

Ok, so I’ve followed the keiser2zwift install instructions altering anything that needed changing from k2z to your m3iPiZeroW - so far can’t get it working - any chance of some written instructions please?

is there something I didn’t need to do ? Or additional missing steps??

thanks in advance

djwasser commented 3 years ago

@Lloydster2000 I have been dragging my feet writing instructions, but will try to do so in the next couple of days (I want use a fresh SD card and start from scratch so I capture everything). So hopefully a tested install procedure available soon!

In the mean time, when you say that you can't get it working -- were you able to trouble-shoot at all? For instance, were you able to try to start the software and get any output at the linux console? Or was the Bluetooth service running on the Pi but just not seen by Zwift? It's hard for me to tell what might not be working without more info...

Lloydster2000 commented 3 years ago

Thanks for the quick reply,

Well, wasn’t sure how closely I was supposed to follow the keiser2z wifi instructions seeing as there’s no second bl dongle required for starters (just skipped ‘sudo hciconfig hci1 up’ otherwise followed everything else on keiser2zwift

it just came with an error when I ran - sudo npm start,

Copied m3iPixxx.service to /etc/systemd/system and rebooted and it came up with another error - no output as service wasn’t running when I checked with ‘ systemctl status m3iPixxx’ - (think I missed a step ‘running without root or sudo’ actually looking back through the instructions)- will try again this evening and add what error if any, is mentioned on the screen as I just gave up on it. (It was getting toowarm by lunch time here in the Uk, so I gave up🥵)

Lloydster2000 commented 3 years ago

image

Lloydster2000 commented 3 years ago

Heres what Ive tried -

sudo systemctl stop bluetooth sudo systemctl disable bluetooth sudo mv /usr/lib/bluetooth/bluetoothd bluetoothd.bak

Install the development requirements sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

Install NVVM to manager Node.js versions (Make sure to close and reopen your shell after this step) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash Install the latest binary build of Node.js to support Pis (anything newer and your need to spend a lot time with building it) nvm install 10.22.0

Download this repo or clone it locally. I put it in a directory off the home folder for pi called /home/pi/code/M3iPiZeroW Go to that directory and run npm install

Make sure 1 bluetooth adapters are connected and issues the following two commands sudo hciconfig hci0 up

Verify that you see one devices when you run: hcitool dev

to find out where node is actually installed and put that path in run.sh. The command for determing this is "whereis node", then edit run.sh if needed- eg add this -

/home/pi/.nvm/versions/node/v10.22.0/bin/node index.js

Start this project manually as root. You should see log messages that indicate its looking for an M3i. npm start

Wake up your bike and do a few revolutions of the pedals. You should see log messages indicating that its connected to that bike Launch Zwift and connect to the Power meter whose name starts with KeiserM3-. Then connect to the Cadence sensor. Enjoy

Running without root/sudo

Run the following command:

sudo setcap cap_net_raw+eip $(eval readlink -f which node) This grants the node binary cap_net_raw privileges, so it can start/stop BLE advertising.

Note: The above command requires setcap to be installed, it can be installed using the following:

apt: sudo apt-get install libcap2-bin

yum: su -c \'yum install libcap2-bin\' << THIS NEVER WORKS FOR ME (backticks??)++

Setting up to always run

You can setup the program to run at Pi boot time by doing the following steps:

Edit the M3iPiZeroW.service file in the root of this project to change the path if you didnt take my suggestion. Copy the service definition into the correct location sudo cp M3iPiZeroW.service /etc/systemd/system Enable the service sudo systemctl enable M3iPiZeroW Start the service (Make sure you aren't still manually running the project using npm) sudo systemctl start M3iPiZeroW Verify it started systemctl status M3iPiZeroW <<<<-----THIS IS WHERE I GET THE ERRORS IN LAST SCREENSHOT Reboot the system and verify that the service started automatically using step 5

djwasser commented 3 years ago

@Lloydster2000 This issure looks familiar.... please take a look at this response to the closed issue "The console is stuck at npm start" in Keiser2Zwift

(also note that there must be "back ticks" surrounding which node in the sudo setcap command which was pointed out in a later response.)

If you can get the "npm start" command (without the sudo prefix) to run from the linux command line, then you should be ok to move on to the next steps to get the service to start automatically. But even without setting up things to start automatically, once you have the app running with npm start you should be able to pedal the Keiser and see power/cadence in Zwift.

Hope this helps!

Lloydster2000 commented 3 years ago

image

found npm and update file, backticks are there it’s just the way it’s formatted in here, still no luck

djwasser commented 3 years ago

@Lloydster2000 ok -- I created detailed instructions at the end of the readme file. I started from scratch (i.e. blank miniSD card) and everything worked. Based on what I am seeing in your screen shot, I am guessing that your system in not finding "node". In step 9 of my instructions I copy the node files to a directory that I know is in path:

sudo cp -r /home/pi/.nvm/versions/node/v10.22.0/* /usr/local/

You might give that a try to see if it fixes your issue, Otherwise the best advice I have is to start with a blank miniSD card and follow the installation instructions.

Hope this helps!

Lloydster2000 commented 3 years ago

Fab- thanks , will have a clean go tomorrow morning. That looks very detailed instruction - very much appreciated!👏👍🏻

Lloydster2000 commented 3 years ago

@djwasser Working! thanks.

Apart from removing the ~4x // from hr in ble/keiser bike- is there anything else I need to do for it to work with my polar h10??

djwasser commented 3 years ago

@Lloydster2000 Great!

Actually there are 5 "//" to remove to enable HR service. I went ahead and removed them so if you update your copy of the repo you should get the updated file. For reference, here are the five lines (with line #s) to uncomment/comment to enable/disable HR service:

5    //const HeartRateService = require('./heart-rate-service');
20   //this.hrs = new HeartRateService();
49   //self.hrs,
93   //this.hrs.notify(event);
118  //this.hrs.uuid,

Since this all worked for you, I will go ahead and close this issue!

Lloydster2000 commented 3 years ago

All working (incl HR)👍🏻👍🏻Will use over next few weeks and see how it goes with/without hr sensor - just to see if I get the ghost hr figures issue you mentioned previously.

Only app that hasn’t worked so far is ‘RGT cycling’ ‘ftms’ shows up but won’t connect keiser converter shows ‘power profile’ and works.

djwasser commented 3 years ago

@Lloydster2000 ok - great that HR works. I have not tried RGT cycling. I know that ftms typically also has feature where software can adjust the resistance of the trainer (which obviously is not available for Keiser!) so maybe that is why it won't connect? When I get a chance I will investigate what is involved in creating a "power profile"...

Lloydster2000 commented 3 years ago

@Lloydster2000 ok - great that HR works. I have not tried RGT cycling. I know that ftms typically also has feature where software can adjust the resistance of the trainer (which obviously is not available for Keiser!) so maybe that is why it won't connect? When I get a chance I will investigate what is involved in creating a "power profile"...

Rouvy connected as ftms and worked in free mode - but it did show an error at the top stating no gear/resistance. Fabulous work - thank you v much.

djwasser commented 3 years ago

@Lloydster2000 Looking through my notes, it does not look like I have connected any software to just the cyclng power service.... so it may be that I did not implement it correctly :-(

I will play around with it when I have some time to see if I can figure out what is going on... but it may not be anytime soon!

But glad you are happy with what is working so far :-)