cagnulein / qdomyos-zwift

Zwift bridge for smart treadmills and bike/cyclette
https://www.qzfitness.com/
GNU General Public License v3.0
353 stars 107 forks source link

iFit Virtual Device Implementation #441

Open jonathancolledge opened 2 years ago

jonathancolledge commented 2 years ago

iFit can't connect to QZ. it sees a machine called I_EB, but can't connect to it. EDIT: i_EB may not be QZ my rower saw that when QZ was off - it looks like ifit can't see any device. I have Virtual iFit turned on

Of note I'm using a Concept2 Rowing Erg with PM5 (my elliptical is in storage as we have moved to a smaller house). QZ connects to the PM5' but says connecting all the time...

debug-Tue_Sep_14_03_56_12_2021.log

hoveeman commented 2 years ago

@cagnulein I was able to get QZ on my iPhone connected to my Echelon Bike and connected to my Android Tablet running iFit. I started a ride in iFit and my resistance adjusted to 100% (16 on iFit and 32 on the echelon). I tapped on follow the instructor for resistance and it would go to 100%. I tried smart adjust and moved the resistance down on the bike. iFit showed the proper resistance I adjusted to, 8 resistance, and then immediately jumped back up to 16. I tried a few different things and it kept going to 16. I had to stop the ride eventually.

Cadence showed up properly in iFit.

Excellent progress! Maybe I had a setting incorrect on my iPhone QZ app?

Attached is the debug log. debug-Sat_Apr_9_13_03_18_2022.log

Dredd2099 commented 2 years ago

Lol mr @hoveeman, think I got a video of it, thanks for the log since I was concentrating on making the video. The 'follow trainer' button keeps popping back up as well in this vid.

https://youtu.be/5sFKdN_T5c8

Initial thoughts:

Note 1 - You should be able to complete a ride as long as you don't touch anything. It's when you touch anything on the tablet that ifit goes haywire. At least from what I can tell. Issue is if it's actually the right resistance, it doesn't change sometimes.

Note 2 - if starting another ride, it's better to close qz completely and reopen otherwise the elapsed time will continue on and skew your stats

Note 3 - reconnection is way better now, it can follow through, sometimes the target cadence goes zero though.

Note 4 - I should write down what happened as it happens so I don't forget, ok so this is more for me 😅

Note 5 - after finishing a workout and pressing stop, ifit sometimes wants you to continue by pulling up a manual workout automatically, Hahaha

Note 6 - distance now shows up, I'm not a zero distance cyclist anymore, yay

Note 7 - ifit connects and sees qz faster and more reliably now.

cagnulein commented 2 years ago

@hoveeman thanks! this is very easy to fix! I forgot to mention also to @Dredd2099 , that the converted resitance from ifit, is also multiplied and offsted by the zwift resistance offset and zwift resistance gain (so you can play with the conversion). Since you have a zwift resistance offset of 20, you're scaling a lot upper the resistance. Put the gain to 1 and the offset to 0 and it should work fine. Maybe I can add a seperate settings for ifit, what do you think?

cagnulein commented 2 years ago

Note 1 - You should be able to complete a ride as long as you don't touch anything. It's when you touch anything on the tablet that ifit goes haywire. At least from what I can tell. Issue is if it's actually the right resistance, it doesn't change sometimes.

thanks, i need a log for this

Note 2 - if starting another ride, it's better to close qz completely and reopen otherwise the elapsed time will continue on and skew your stats

yes i need to clear the timer data when i'm receiving the stop event. I'm doing this right now

Note 3 - reconnection is way better now, it can follow through, sometimes the target cadence goes zero though.

target cadence on ifit or qz? i didn't handled on QZ and actually I didn't know ifit has it. I need a debug log for this or at least knowing which workout were you doing

Note 5 - after finishing a workout and pressing stop, ifit sometimes wants you to continue by pulling up a manual workout automatically, Hahaha

yes i see this too. i guess We can say that this is a minor but I know how to fix it :)

hoveeman commented 2 years ago

@hoveeman thanks! this is very easy to fix! I forgot to mention also to @Dredd2099 , that the converted resitance from ifit, is also multiplied and offsted by the zwift resistance offset and zwift resistance gain (so you can play with the conversion). Since you have a zwift resistance offset of 20, you're scaling a lot upper the resistance. Put the gain to 1 and the offset to 0 and it should work fine.

Maybe I can add a seperate settings for ifit, what do you think?

Ah, this makes sense. I thought about playing with those numbers. Good to know. Thank you!!!

It would make sense to have another setting for iFit. However, it's also a fine balance with the amount of configuration options you have an overwhelming the user.

As your app keeps integrating with more apps. Maybe there will be a time in the settings to enable/disable peloton, ifit, zwift, etc compatibility and then under those sections are all of the settings respective to the workout app you're using. You have some of this right now.

cagnulein commented 2 years ago

@hoveeman yes, it's exact what i have in mind! let me know if now with that values it will work ok! Have a nice sunday!

Dredd2099 commented 2 years ago

Note 3 - reconnection is way better now, it can follow through, sometimes the target cadence goes zero though.

target cadence on ifit or qz? i didn't handled on QZ and actually I didn't know ifit has it. I need a debug log for this or at least knowing which workout were you doing

20220410_093954

It only shows up if using a chromebook or tablet. Phones does not have it. For me, it's minor as instructors usually and mostly go for RPE as opposed to calling out cadence all the time. Heck, sometimes they say a different cadence altogether too than what is posted.

Extra: the swag bag is a great addition 😁 is there a way to add the coffee/patreon link there too? Those get buried in the FB group

Have a great weekend sir

Edit: Disregard mr @cagnulein . It's not only qz that need to be restarted when starting another ride, got to do with ifit as well. Target cadence goes to zero going to cooldown after a workout. If you start another workout, it'll just stay on zero. I've been cycling a lot lately 😅

cagnulein commented 2 years ago

Hah strange that it's available only there: and also, being a target one, it should send BY the app and not from QZ so it's really strange.

Swag bag: thanks! No I can't put a buy me a coffee or patreon link because it's against the Apple rules

BCarltonMarine commented 2 years ago

Good to see that a lot of work has been put into this thread! I also did another test April 7th and things seemed to run a little smoother. I made a little video that I will attach. Overall I was able to make it through the whole ride with little issues.

debug-Thu_Apr_7_21_10_19_2022.zip debug-Thu_Apr_7_21_10_19_2022.log https://youtu.be/Eze4zCWqV0w

cagnulein commented 2 years ago

thanks @BCarltonMarine are you sure these are the right log? i don't see any ifit communication in there. Maybe you have other files in the debug folder?

cagnulein commented 2 years ago

Guys any news about this?

Dredd2099 commented 2 years ago

The bluetooth disconnect is back for me. QZ on android, ifit on chromebook. Was trying to test more of the auto resistance again which refuses to work on multiple classes.

Edit: I think it's a chromebook issue. If using iOS or Android tablet, it can find and continue on.

20220420_110059

debug-Wed_Apr_20_11_17_10_2022.log

Here's a vid of no auto resistance but manual changes works beautifully. QZ on iOS, ifit on chromebook. Forgot the log again though.

https://youtu.be/VTAizZ5RtaM

Here's a log where both auto and manual resistance both don't work. QZ on android phone, ifit on android tablet. debug-Wed_Apr_20_12_44_06_2022.log

Log for 'follow trainer' keep on popping back up. QZ on iPhone, ifit on android. debug-Wed_Apr_20_13_12_50_2022.log

cagnulein commented 2 years ago

Thanks @Dredd2099 I will check the logs!

Dredd2099 commented 2 years ago

QZ on android phone. Ifit on android tablet. Full ride. Left it for first 9 minutes and it just stayed the same. Started playing around after that. It seems auto resistance keeps getting overruled by the manually set resistance. Few disconnect/reconnects that it was able to push through.

20220420_220317

https://youtu.be/SKyQFEJ4G58

debug-Wed_Apr_20_19_47_04_2022.zip

cagnulein commented 2 years ago

Log for 'follow trainer' keep on popping back up. QZ on iPhone, ifit on android. debug-Wed_Apr_20_13_12_50_2022.log

this log is empty. maybe you have another one for this?

Here's a log where both auto and manual resistance both don't work. QZ on android phone, ifit on android tablet. debug-Wed_Apr_20_12_44_06_2022.log

I see some requests to change the resistance in there but you have the "Zwift Force Resistance" setting off. That's why the auto resistance doesn't work. Please turn it on

debug-Wed_Apr_20_11_17_10_2022.log

still the same: don't touch smart adjust. Once you touch that, it's not going to come back to 'follow trainer' no matter how many times to tap on it 😅

also this log is empty :(

Let me know after putting the "Zwift Force Resistance" on if it's better.

Dredd2099 commented 2 years ago

Ty sir. Will do. Zwift force resistance on. Still same, I probably have another setting wrong again.

debug-Thu_Apr_21_10_06_31_2022.log

Also tried to do a live ride to check it out. Connects as per usual but can't get past an error message after.

20220421_060747

debug-Thu_Apr_21_06_27_44_2022.log

On another note, manual resistance changes works beautifully. I should post this on the FB group too 😁

https://youtu.be/VTAizZ5RtaM

cagnulein commented 2 years ago

Ty sir. Will do. Zwift force resistance on. Still same, I probably have another setting wrong again.

debug-Thu_Apr_21_10_06_31_2022.log

about this, i don't see an ifit init phase. If it's the right log, means that you didn't run a clean session. for a clean session I mean: ifit and qz closed, open qz, connect to the bike, then open ifit and select a workout on ifit and connect to QZ. Is what you're doing?

cagnulein commented 2 years ago

@Dredd2099 is possible that your log was crossed? the second one is the first one and viceversa?

Dredd2099 commented 2 years ago

@cagnulein you could be right. I'm going to concentrate on just one device mix and get to the habit of clearing sessions so I don't get confused.

Also yes on getting the habit of connecting to a clean session, it's the only way I find to work reliably. Ty for all the assist sir. Will provide more feedback as I get to test more.

cagnulein commented 2 years ago

debug-Thu_Apr_21_06_27_44_2022.log

on this log I see automatic resistance working! Check these lines

here iFit is asking resistance 26

Thu. Apr. 21 06:30:06 2022 1650537006093 Debug: ../src/virtualbike.cpp void virtualbike::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "requested iFit resistance 26"

and the conversion in the echelon resistance is 30 and i'm writing it to your bike

Thu. Apr. 21 06:30:06 2022 1650537006131 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::update() "writing resistance 30" Thu. Apr. 21 06:30:06 2022 1650537006600 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "Current resistance: 30"

here ifit is asking resistance 33

Thu. Apr. 21 06:30:13 2022 1650537013555 Debug: ../src/virtualbike.cpp void virtualbike::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "requested iFit resistance 33"

and i'm writing resistance 32 to echelon

Thu. Apr. 21 06:30:13 2022 1650537013744 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::update() "writing resistance 32" Thu. Apr. 21 06:30:14 2022 1650537014602 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "Current resistance: 32"

then ifit wants resistance 9

Thu. Apr. 21 06:30:32 2022 1650537032243 Debug: ../src/virtualbike.cpp void virtualbike::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "requested iFit resistance 9"

and i'm writing resistance 14 to echelon

Thu. Apr. 21 06:30:32 2022 1650537032330 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::update() "writing resistance 14" Thu. Apr. 21 06:30:32 2022 1650537032703 Debug: ../src/echelonconnectsport.cpp void echelonconnectsport::characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &) "Current resistance: 14"

and so on...Am I missing something?

cagnulein commented 2 years ago

debug-Thu_Apr_21_10_06_31_2022.log

if this is a live, I guess it wasn't a clean start because I saw the log starting directly with a request 11 that means that ifit believes that the bike was already connected. Could you try again?

Dredd2099 commented 2 years ago

debug-Thu_Apr_21_10_06_31_2022.log

if this is a live, I guess it wasn't a clean start because I saw the log starting directly with a request 11 that means that ifit believes that the bike was already connected. Could you try again?

Here's one where I tried joining an existing (joining mid way) live ride. Same error code: 65013. Once you press ok and stop, it'll go to its usual manual workout track. debug-Fri_Apr_22_10_10_27_2022.log

Edit: tried joining prior to start, still the same.

Dredd2099 commented 2 years ago

debug-Thu_Apr_21_06_27_44_2022.log

on this log I see automatic resistance working!

Yup, I know it's supposed to work. I can actually see it changing. The issue is you'll have to keep tapping on 'follow trainer', it seems to always pop back up. Otherwise it's just going to remain at whatever resistance is on. Let's go testers, I can't figure out what I'm doing wrong, I need feedback too 😅 Here's another log in case it'll reveal something else than the last one. debug-Fri_Apr_22_10_49_09_2022.log

cagnulein commented 2 years ago

@Dredd2099 is possible that when it asks for a resistance qz set it but a different one? and so the follow trainer feature goes mad? if so i think it can be easily fixed

Dredd2099 commented 2 years ago

Yes sir, something is definitely tripping it up.

cagnulein commented 2 years ago

@Dredd2099 Ok I have something in mind in order to fix it! Tomorrow I will send you a new version with a possible fix

cagnulein commented 2 years ago

@Dredd2099 version sent ;)

Dredd2099 commented 2 years ago

@cagnulein version update works 😁 If using tablet, turn on 'smart adjust', if too hard, turn it back off. If using phone, leave as is. Then everything is followed to the letter.

Screenshot_20220424-210840_Gallery

cagnulein commented 2 years ago

yeah @Dredd2099 ! so now the only big issue is with live classes? or are there others blocking issues?

Dredd2099 commented 2 years ago

Yes sir, just tried to do some live classes, still the same error code 65013. Connects fine but once it starts the workout, it trips up. It's low priority for me personally since iFit studio rides aren't really that great 😅

Still the same: ifit keeps opening the manual workout track after hitting pause/stop. Since need to start a clean set if doing another workout anyway, force closing then restarting ifit works just fine.

Ty sir, great work.

cagnulein commented 2 years ago

thanks, for live workout I guess I need a hci snoof from a real ifit bike during a live class.

pushing3am commented 2 years ago

Hello Roberto - I am using a Galaxy Tab to run iFit and a galaxy s21 for QZ. I was able to get connected just fine but throughout the iFit workout the Bluetooth was loosing connection pretty frequently, it would generally reconnect after just a few seconds but sometimes it took longer.

Here is the log, thanks for your help!!

debug-Sun_May_15_22_33_17_2022.log

cagnulein commented 2 years ago

@pushing3am i see the error, it seems that ifit doesn't get my answer sometimes. it could be an issue on one of the 2 devices. Anyway this is the idea that I had in order to workaround to it: i can send the frame again if i don't receive a new request, this should be prevent this issue. send me an email to roberto.viola83 at gmail.com indicating this ticket and that you are on android and I will add you to the private beta (you have to quit from the public beta first). Thanks

pushing3am commented 2 years ago

Hi Roberto - here is the latest log file. Similar issues as before with the Bluetooth reconnects. Thanks again for all your help. debug-Mon_May_16_21_04_12_2022.zip

cagnulein commented 2 years ago

good news @pushing3am I did a stupid error in my last version so the patch didn't apply correctly. So i will push another one today!

pushing3am commented 2 years ago

Attaching the latest log file. Let me know if a short video of the error or anything else would be useful. Thanks!! debug-Tue_May_17_12_28_15_2022.log

cagnulein commented 2 years ago

thanks @pushing3am error saw, now i have to understand how to solve it. I will let you in the next days

cagnulein commented 2 years ago

problem fixed @pushing3am i hope the new one will be the good one ;)

pushing3am commented 2 years ago

Here is the latest, thanks! debug-Thu_May_19_12_09_55_2022.log

cagnulein commented 2 years ago

@pushing3am ok the workaround that I did worked but it cause a newer issue, so it doesn't seem to be the right way. I need to revert it. Do you have also an iOS device to use for QZ? I would like to see if it's better. I never tried qz android to ifit android so maybe this is causing this. I would like to check the qz ios to ifit android scenario. Let me know

cagnulein commented 1 year ago

debug-Sun_Aug_21_08_31_18_2022.log new packet to handle

kadaan commented 1 year ago

QZ iOS to iFit android seems to work quite well. The main issue I have is when the workout is over iFit gets to the finish page. Once closing the finish page iFit hangs for a while with the text "Loading workout". Then it changes to saying "Canceling workout". I've waited a while and this never seems to end. I have to force close iFit and then reopen it to be able to move on.

cagnulein commented 1 year ago

yes it's a known issue. probably i have to handle the end frame but i need a debug log from a real ifit device to do so. is this blocking?

kadaan commented 1 year ago

Nope, just annoying. Hopefully someone with a real iFit machine can provide an example end frame. Do you know if there are any QZ users with real iFit devices?

cagnulein commented 1 year ago

yes sure, there are a lot. and also there are a lot here on github too. we can check on previous ifit logs that i used to implement ifit devices on qz but it will take a while