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

#855 Support for the Trixter X-Dream V1 bike #899

Open
wants to merge 331 commits into
base: master
Choose a base branch
from

Conversation

drmason789
Copy link
Contributor

#855

I've partially added the virtual device but in the wrong place. Not really sure where this is supposed to go or how to connect the bike's features to BT.

It's delivering:

  • speed
  • cadence
  • heart rate
  • steering

To use, the bike must first be enabled in Settings / Bike Options / Trixter X-Dream V1 Bike Options. From there you can turn the steering on and off, and adjust the steering calibration, which allows the user to specify which uncalibrated steering values are to be mapped to -45, dead zone left, dead zone right, +45.

src/bluetooth.h Outdated Show resolved Hide resolved
@drmason789
Copy link
Contributor Author

I should squash these commits. Please wait...

@cagnulein
Copy link
Owner

if you want i can squash it during the merge

@drmason789
Copy link
Contributor Author

Okay, thanks.

@cagnulein
Copy link
Owner

i would like to release the actual master as the official 2.11 the next week or so, so i will merge this in the 2.12
thanks!

@drmason789
Copy link
Contributor Author

It would be nice to have the virtual device hooked up so I can get my contacts in the Trixter X-Dream v1 bike community testing builds.

@cagnulein
Copy link
Owner

hah ok i will check this on your branch.

@cagnulein
Copy link
Owner

@drmason789 I checked your virtual bike implementation and it seems fine to me. Don't you see power over FTMS? could you show me on nrfconnect what you see from your QZ interface?

also i had an idea: why don't you use a bluetooth-serial port adapter? so you can use your module over bluetooth with an ipad or a phone for example, i guess will be more confortable than a PC ;)

@drmason789
Copy link
Contributor Author

drmason789 commented Aug 14, 2022

@cagnulein Thanks. I am running Zwift on my Android phone and when I run QZ on my PC (which has Bluetooth, but perhaps not the right version) it doesn't advertise the services. When I run QZ on my Raspberry Pi 4, it advertises the DomyosBridge, power sensor (but not speed), heart rate, cadence and controllable.

I was able to connect those 4, and I was able to start a ride. The heart rate worked, and when I pedalled, the cadence was indicated, but the power shown remained 0W, the bike didn't move, and there was no indicator of speed. No sign of how to configure steering.

Do I need my bike subclass to provide power information?

  • The bike doesn't give a power reading, but there is a table in the associated software's config that provides a mapping between cadence RPM, resistance, and power that I could incorporate. However, the solenoids can wear out, and slip away from the flywheel, so this could be inaccurate. Better than nothing I guess.

A bluetooth serial port adapter? The bike is externally USB, but it is exposed in the OS as a serial port. I'm not sure if a suitable device exists. I could possibly solder a serial to Bluetooth adapter into the internal board, but I want to provide something that anyone with one of these bikes can use.

@drmason789
Copy link
Contributor Author

Also, on the RP4 it crashed once with a "bus error".

@drmason789
Copy link
Contributor Author

Screenshot_20220815-003238_nRF Connect

Screenshot_20220815-003311_nRF Connect

Screenshot_20220815-003316_nRF Connect

@cagnulein
Copy link
Owner

cagnulein commented Aug 15, 2022 via email

@cagnulein
Copy link
Owner

saw the commit. does the power work on ftms now?

@drmason789
Copy link
Contributor Author

drmason789 commented Aug 15, 2022

It detects the device and runs but doesn't advertise on my PC and my RP4 is no longer reading the USB serial port (it sees the port but times out waiting for recognisable data - log shows no bytes coming in from serial port) RP4 on same power supply (this can affect USB device AFAIK) as when it was reading the bike yesterday. I will resume this after work this evening.

@cagnulein
Copy link
Owner

for the pc issue use this dongle that must work https://github.com/cagnulein/qdomyos-zwift/wiki/I-can't-connect-QZ-to-Zwift#for-zwift-pc-users

@drmason789
Copy link
Contributor Author

@cagnulein I just took a ride and got the Zwift bike to move. However, Zwift displays a speed in kph of about 1/10 or less the speed shown by QZ. Needless to say, I didn't ride very far.

@drmason789
Copy link
Contributor Author

I'm going to have to take a careful look at other bikes' power calculations.

@cagnulein
Copy link
Owner

@drmason789 that's right because zwift does it's own speed calculation based on power and variables in the game. so it's totally right
you need to increase the resistance on your bike ;)

@cagnulein
Copy link
Owner

so which is the status of this? is it working ok with zwift? also with auto resistance?

@drmason789
Copy link
Contributor Author

Zwift is responding to it, but as for working okay, I don't really know what "okay" is as I've never used Zwift before. If my interpretation is correct, Zwift requests about 2% resistance from the bike, I pedal fast, Zwift shows the watts I expect, but the Zwift bike only moves at 1-10km/h.

I've adjusted one of the Zwift settings in QZ and this appears to alter the W that appears in Zwift, but no real improvement in the user experience. I guess I've just got to learn what the Zwift related options mean, and do some prodding and poking to figure out which options to set.

Also, it's not really clear which metrics my bike subclass needs to populate. E.g. I only found out from connecting to Zwift and asking you that I actually need to provide a power reading - I had been working on the assumption that cadence and speed would be enough. Now I wonder, do I need to populate WattKg (which I see from calculations is actually watts per kg)? I am currently using the update_metrics method inherited from the buetoothdevice class.

To assist with my prodding and poking, I've started connecting the bike's 2 brake levers which deliver values from 135 to 250 to the system to adjust items, starting with the resistance/power calculations, i.e. to squeeze a lever to see what effect the parameter has on the user experience.

@cagnulein
Copy link
Owner

Zwift is responding to it, but as for working okay, I don't really know what "okay" is as I've never used Zwift before. If my interpretation is correct, Zwift requests about 2% resistance from the bike, I pedal fast, Zwift shows the watts I expect, but the Zwift bike only moves at 1-10km/h.

that's because you need to adjust the zwift resistance gain to 10 or 15 in your case since you have 250 resistance levels. qz is translating inclination to resistance using the zwift
inclination gain and offset.

Also, it's not really clear which metrics my bike subclass needs to populate. E.g. I only found out from connecting to Zwift and asking you that I actually need to provide a power reading - I had been working on the assumption that cadence and speed would be enough. Now I wonder, do I need to populate WattKg (which I see from calculations is actually watts per kg)?

calling the metric method update it will automatically calculate the wattkg. but zwift wants only power. cadence and heart rate are optional

I am currently using the update_metrics method inherited from the buetoothdevice class.

perfect so you already did what was necessary.

@drmason789
Copy link
Contributor Author

Currently the bridge doesn't stay connected long enough to do anything, and looking at the debug log, it seems to be confused about a Wahoo Kicker bike that shows up in Zwift on my phone. I guess this is my neighbour's smart trainer.

I also see references to dircon in the log. I disabled dircon in the settings.

Still, the bluetooth won't stay connected long enough to do anything - it just jumps to "No Signal" very quickly. Cadence no longer advertised.

I'll continue looking another day.

@cagnulein
Copy link
Owner

cagnulein commented Aug 18, 2022 via email

@drmason789
Copy link
Contributor Author

Problem is on the RP4. I did get the dongle, but it makes no difference on the PC - still doesn't advertise. Possibly interfering with the built in bluetooth - I'll have to investigate that. Development on Windows is so slow I may ditch this environment and create a Linux one in a VM.

@cagnulein
Copy link
Owner

@drmason789 did you try the dongle on the pc instead?

@drmason789
Copy link
Contributor Author

@cagnulein Yes, I only used the dongle on the PC.

@cagnulein
Copy link
Owner

since #898 is merged now, are we waiting other tasks before merging this? @drmason789

@drmason789
Copy link
Contributor Author

I need to find out why I can't maintain a bluetooth connection and suitable settings so I can get the Zwift bike going more than 10km/h.

@drmason789
Copy link
Contributor Author

QZ is currently crashing with

Tue Aug 23 23:27:52 2022 1661293672271 Debug:   sending notification/indication: "1b0a006402061fc00005000e000000"
qt.bluetooth.bluez: sending notification/indication: "1b0a006402061fc00005000e000000"
Tue Aug 23 23:27:52 2022 1661293672272 Debug: virtualbike.cpp void virtualbike::writeCharacteristic(QLowEnergyService*, const QLowEnergyCharacteristic&, const QByteArray&) "virtualbike::writeCharacteristic Heart Rate Heart Rate Measurement 00 00"
"virtualbike::writeCharacteristic Heart Rate Heart Rate Measurement 00 00"
Tue Aug 23 23:27:52 2022 1661293672273 Debug:   sending notification/indication: "1b14000000"
qt.bluetooth.bluez: sending notification/indication: "1b14000000"
Tue Aug 23 23:27:52 2022 1661293672374 Debug:   HCI event triggered, type: 13
qt.bluetooth.bluez: HCI event triggered, type: 13
free(): invalid pointer
Aborted

@drmason789
Copy link
Contributor Author

I connected the brake values to the watt output to boost to 250W but the resistance (with Zwift resistance gain set to 15 and 100, with Zwift Resistance offset 4) never seems to change on the bike.

drmason789 and others added 22 commits March 19, 2024 20:02
…eam-v1-bike

Adjusted tests for X-Dream. Not working currently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants