Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for resistance change #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

roberttod
Copy link

@roberttod roberttod commented Sep 19, 2020

@ptx2 I was inspired after reading your dev notes a couple of months ago and ended up attaching a raspberry pi to my spin bike, https://www.diamondbackfitness.com/products/510ic-indoor-cycle . The down button for resistance was broken on the bike's built in screen so I replaced all of the logic with a pi and connected it to zwift using gymnasticon. Because of all the hardware involved I had to write the logic in python, which I connected to the "bot" bike using a UDP connection.

I built a custom UI (before I connected to zwift) where I can change the resistance, but changing apps from zwift to my UI to change resistance isn't the easiest thing to do while working out, so thought I'd try to build the BLE resistance change logic.

I've started to build out some BLE characteristics in this PR and the pi now shows up in zwift as supporting resistance change. I'm wondering if you could help point me in the right direction.

A couple of things I'd love some help with

  • The BLE GATT docs are almost impossible to read! I'm not sure how you managed to connect everything just from the spec, were there any other resources you used to figure out the UUIDs and protocols?
  • Do you know how the zwift command to change resistance would come through to a bleno characteristic? I was monitoring onWriteRequest but didn't see anything (I'm not really sure when zwift updates resistance, I assumed it would reset it at the start but perhaps I need to choose a hilly course to see it change)

Thanks so much for building this project and inspiring me, it's been nice to get back into electronics!

@ptx2
Copy link
Owner

ptx2 commented Sep 20, 2020

Hi, thanks for opening this, it would be excellent to add FTMS support!

I still need to read up on FTMS and I have only skimmed the PR so far, but just quickly: it looks like characteristic 2AD6 might still need to be implemented? (org.bluetooth.characteristic.supported_resistance_level_range)

I agree on the PDFs. It might be easier to start with the GATT XML spec and refer back to the PDF to fill in the blanks. The XMLs used to be on developer.bluetooth.org but I can't find them there anymore. They're all over the web though, e.g.:

https://github.com/oesmith/gatt-xml
https://github.com/oesmith/gatt-xml/blob/master/org.bluetooth.service.fitness_machine.xml
https://github.com/oesmith/gatt-xml/blob/master/org.bluetooth.characteristic.supported_resistance_level_range.xml

btmon(1) is very useful for catching things that don't bubble up to the app.

It may also be worth having a look at the websites of Nordic and SiLabs and other BLE chip makers, as they often have developer resources, blog posts, reference implementations, forums, etc.

I'll try to have a better look at this a little later, hope this helps, let me know how it goes!

@roberttod
Copy link
Author

Thanks! That's exactly what I was looking for!

I'll leave the PR as a draft until I finish the implementation, it's only half done as it stands so might not be that much value but thought it was worth at least sharing where I'm at so far. Hopefully I'll be able to make some progress over the next couple of weeks.

Base automatically changed from master to main February 23, 2021 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants