cagnulein / qdomyos-zwift

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

Horizon 7.4 Treadmill starts on its own after app launch #923

Closed RickNY closed 2 years ago

RickNY commented 2 years ago

After starting the QZ app with a Horizon 7.4 AT-02 Treadmill running firmware version 5.001, the treadmill will start moving on its own approximately 30 seconds after the app is launched and connects. The treadmill sets itself to 0.5 mph along with a countdown timer for 30 minutes. The speed in the QZ app updates, but pressing the "Stop" button in the QZ app does not stop the treadmill when it has started this way. The only way to stop is to press the stop button on the treadmill itself. Note that this only occurs when the QZ app is connected, I could not reproduce this behavior with the Horizon AFG Pro app.

Treadmill is running firmware version Collected a debug log from a RPi when the action occurs.. Note on the Rpi the action took a bit longer than 30 seconds before the treadmill started on its own. debug-Fri_Sep_2_21_14_58_2022.log.txt

RickNY commented 2 years ago

Here is the flow from the AFG app: 1) App opens and connects. In the app, here is where you select the profile, the program and then press Start the first time 2) This takes you to a 2nd screen where you set initial incline, speed, and time - and then press Start. This causes treadmill to countdown and begin moving

This log is Start (to get to 2nd screen), then Start (to start treadmill), Pause, Start, Pause, Start, Pause, STOP.

I only mention that first Start because I'm not sure if it sends any bluetooth command back to the treadmill thgat you see in the log

H74_3.zip

cagnulein commented 2 years ago

perfect @RickNY got the resume command

55aa130003030100d1f101

i'm implementing this

cagnulein commented 2 years ago

done @RickNY pull and build it as usual, thanks!

RickNY commented 2 years ago

OK.. Some progress on this.. Pause worked, and treadmill reported "Workout Paused".. Then I waited around 30 seconds before resuming again and pressed the start button in QZ -- no response from treadmill... I did this two or three more times with no response -- and then last time I tried, the treadmill resumed and started running again. Heres the log

debug-Wed_Sep_7_08_01_55_2022.log.txt

cagnulein commented 2 years ago

ah! i got the issue @RickNY , my fault. I'm fixing it!

cagnulein commented 2 years ago

done @RickNY pull & build as usual ;) thanks!

RickNY commented 2 years ago

OK.. Pause/resume is now working well - as long as these actions are initiated from within QZ and not on the treadmill itself. If you attempt to pause on the treadmill by pressing the "stop" button, the treadmill will display "workout paused" -- but it will break the connection to QZ and not reconnect.. As far as I know - I believe this same behavior as always.

janabouc commented 2 years ago

I have the same experience so I don’t Peres stop on the treadmill until I’m all done. If i need to jump off to do something for a couple minutes i leave it running at .5 and pause QZ and Peloton.

On Wed, Sep 7, 2022 at 3:56 PM RickNY @.***> wrote:

OK.. Pause/resume is now working well - as long as these actions are initiated from within QZ and not on the treadmill itself. If you attempt to pause on the treadmill by pressing the "stop" button, the treadmill will display "workout paused" -- but it will break the connection to QZ and not reconnect.. As far as I know - I believe this same behavior as always.

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/qdomyos-zwift/issues/923#issuecomment-1239988922, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONHDMIJJHA5LA5MSOUSOKTV5EMR7ANCNFSM6AAAAAAQDWNBRA . You are receiving this because you were mentioned.Message ID: @.***>

-- Jana Bouc Website and Blog http://janabouc.com Instagram https://www.instagram.com/janabouc/ Facebook https://www.facebook.com/jana.bouc

cagnulein commented 2 years ago

OK.. Pause/resume is now working well - as long as these actions are initiated from within QZ and not on the treadmill itself. If you attempt to pause on the treadmill by pressing the "stop" button, the treadmill will display "workout paused" -- but it will break the connection to QZ and not reconnect.. As far as I know - I believe this same behavior as always.

is the hybrid scenario working with the treadmill app? if so i need another hci snoof with this scenario unfortunately

RickNY commented 2 years ago

OK, snoop attached. Here were the actions:

1) Start (Tread), Pause (Tread) 2) Start (App), Pause (App) 3) Start (Tread), Pause (App) 4) Start (App), Pause (Tread) 5) Stop (App) hybrid_74.zip

cagnulein commented 2 years ago

i guess i got it, the developer were drunk for sure. When you press the pause/start button on the treadmill and you are connected to the tread, the tread send a pause request to the app and the app have to react with a pause command

the pause request should be

55aa0000030002005c480300 handle 14

the start request should be

55:aa:00:00:03:03:01:00:f0:e1:00 handle 14

let me try to implement this

cagnulein commented 2 years ago

@RickNY please pull it and build it. Just to clearify: it's really a mess, so I hope that I got it, but I'm not 100% confident. Probably we need several test & modification

RickNY commented 2 years ago

OK, nope - you were right - its a mess. LOL.. Note - this log was all pause/resume from app only, I didnt do any treadmill stop/pause actions:

1st Pause from App - stopped the treadmill instead of pausing -- hitting Start in app again started a new workout on treadmill. 2nd Pause from App -- paused the workout. Hitting start in app again resumed it on treadmill. 3rd Pause from App -- same as 1st, full stop. Start started new workout 4th Pause from App -- same as 1st, full stop. Start started new workout Stop button in app - stopped treadmill and pulled up graphs in app.

debug-Fri_Sep_9_09_03_53_2022.log.txt

cagnulein commented 2 years ago

ok so these frames are sent also with the app commands, so i have to refine the filter

cagnulein commented 2 years ago

ok @RickNY i reverted the last changes, could you please pull and build again and collect me a debug log from QZ where

you start the tread from the app, then you pause it from the treadmill and then you try to start again from the app? I would like what QZ sees from this scenario

Thanks

RickNY commented 2 years ago

OK... Log attached. Started with Start button in QZ.. At 30 seconds elapsed in QZ, pressed Stop on treadmill -- treadmill paused but elapsed time in QZ continued. At 60 seconds, pressed Start in QZ -- that caused elapsed time to stop counting up in QZ and no response from the treadmill - I gave it another 30 seconds or so before closing the app.
debug-Mon_Sep_12_07_31_34_2022.log.txt

cagnulein commented 2 years ago

perfect @RickNY now I got the logic. Pull it and build it. Try again the same scenario. If now works, I guess we should try to to add also the stop event from the treadmill (and then try to start again from QZ, this scenario shouldn't work, so I will need a debug log)

Let me know and thanks again for the collaboration :)

RickNY commented 2 years ago

OK, this was better.. Started with Start button in QZ.. At 30 seconds elapsed or so, pressed Stop on treadmill. Treadmill paused and QZ also paused. Pressed Start in QZ, and treadmill resumed as did elapsed time in QZ. debug-Mon_Sep_12_08_11_21_2022.log.txt

RickNY commented 2 years ago

One other note about the last attempt.. After treadmill resumed -- I pressed Stop in QZ to end the workout.. I got the graphs, but I just noticed now that the treadmill itself is paused, not stopped

cagnulein commented 2 years ago

One other note about the last attempt.. After treadmill resumed -- I pressed Stop in QZ to end the workout.. I got the graphs, but I just noticed now that the treadmill itself is paused, not stopped

fixed, let me know

RickNY commented 2 years ago

OK, this time behavior was same as last - but Stop worked on the tread itself as well. debug-Mon_Sep_12_17_46_26_2022.log.txt

cagnulein commented 2 years ago

@RickNY so we are fine with this start pause stop events?

RickNY commented 2 years ago

@RickNY so we are fine with this start pause stop events?

Not exactly... Just did a few tests:

1) If the treadmill is started before QZ is opened, waiting 45-60 seconds after QZ opens and pressing "Start" causes QZ to actually pause the treadmill. I brought up this scenario because this is how @janabouc mentioned she uses it -- I've also begun starting it in this way 2) If you pause/resume treadmill using the treadmill's stop/start button, QZ becomes disconnected and no longer resumes. debug-Tue_Sep_13_08_07_11_2022.log.txt

cagnulein commented 2 years ago

2. If you pause/resume treadmill using the treadmill's stop/start button, QZ becomes disconnected and no longer resumes. debug-Tue_Sep_13_08_07_11_2022.log.txt

yes because probably a new init session it's necessary. I would like to fix this, after fixing the profiles thing. (I would like to remove the 45-60 seconds issue)

  1. If the treadmill is started before QZ is opened, waiting 45-60 seconds after QZ opens and pressing "Start" causes QZ to actually pause the treadmill. I brought up this scenario because this is how @janabouc mentioned she uses it -- I've also begun starting it in this way

do you have a debug log of this?

RickNY commented 2 years ago

My last post had debug log of that issue in it, yes.

cagnulein commented 2 years ago

@RickNY i checked the log, did you try to leave QZ without touching anything in the scenario 1? The code should auto adapt the UI when it finally connects to the treadmills showing the pause icon. I saw several start press during the init phase in the log, that's why i'm asking.

My idea is that, reducing the 45-60s to 1s (as i have an idea in mind), all these 2 issues should go away.

Let me know

RickNY commented 2 years ago

OK, was going to try and collect a debug with only that issue in it -- but encountered something else. This time, I manually started treadmill and then started QZ. After waiting appx 60 seconds, attempting to press Start in QZ doesnt start anything.. The speed in QZ does not update, nothing on the treadmill responds to any QZ commands. Log attached

debug-Tue_Sep_13_08_26_33_2022.log.txt

cagnulein commented 2 years ago

OK, was going to try and collect a debug with only that issue in it -- but encountered something else. This time, I manually started treadmill and then started QZ. After waiting appx 60 seconds, attempting to press Start in QZ doesnt start anything.. The speed in QZ does not update, nothing on the treadmill responds to any QZ commands. Log attached

debug-Tue_Sep_13_08_26_33_2022.log.txt

the treadmill seems to doesn't answer to some messages from QZ, leading to a desync. Again, I think we have to recheck all of these after the profiles fix

RickNY commented 2 years ago

OK, Im not sure if something is being left open in-between program runs or not - but I decided to do a fresh reboot of Pi & treadmill. On first launch, I started treadmill ahead of time and set to 1.0 mph.. Then started QZ.... On this launch -- I did not have to press Start -- after the init, it eventually picked up and displayed speed and if I recall, the Start button in QZ changed to Pause.

I do think something may be still running when ending QZ -- as it is now with the Pi, when I quit QZ it does not terminate the BT connection to the tread -- I have to turn Bluetooth off on the Pi for the light to go out on the tread.

debug-Tue_Sep_13_08_34_09_2022.log.txt

cagnulein commented 2 years ago

OK, Im not sure if something is being left open in-between program runs or not - but I decided to do a fresh reboot of Pi & treadmill. On first launch, I started treadmill ahead of time and set to 1.0 mph.. Then started QZ.... On this launch -- I did not have to press Start -- after the init, it eventually picked up and displayed speed and if I recall, the Start button in QZ changed to Pause.

ok so this is good, right?

I do think something may be still running when ending QZ -- as it is now with the Pi, when I quit QZ it does not terminate the BT connection to the tread -- I have to turn Bluetooth off on the Pi for the light to go out on the tread.

yes this is about #939 :)

so are you ok with proceding with the profiles issue?

RickNY commented 2 years ago

OK, Im not sure if something is being left open in-between program runs or not - but I decided to do a fresh reboot of Pi & treadmill. On first launch, I started treadmill ahead of time and set to 1.0 mph.. Then started QZ.... On this launch -- I did not have to press Start -- after the init, it eventually picked up and displayed speed and if I recall, the Start button in QZ changed to Pause.

ok so this is good, right?

I think its good -- because it provides visual confirmation that the init has completed. If I am not mistaken, this isn't much different than the behavior in the current iOS beta -- I think the only thing that was a concern was the fact that if you did nothing at all - as in treadmill on but not running and opening QZ -- that the tread would start on its own after the init was complete.

I do think something may be still running when ending QZ -- as it is now with the Pi, when I quit QZ it does not terminate the BT connection to the tread -- I have to turn Bluetooth off on the Pi for the light to go out on the tread.

yes this is about #939 :)

so are you ok with proceding with the profiles issue?

Sure!

cagnulein commented 2 years ago

I think its good -- because it provides visual confirmation that the init has completed.

yes and with the profile fixed, we shouldn't be afraid of this anymore

If I am not mistaken, this isn't much different than the behavior in the current iOS beta

it's quite different because the beta have the issue about the fact it starts on their own as you said

Sure!

ok from now on, I will work on the profile. It could break something at the very begininng, so don't get discouraged :)

cagnulein commented 2 years ago

done @RickNY , pull it and build and fasten your seat :D if i did right, the init phase should last just some seconds without touching the profiles. Let me know!

RickNY commented 2 years ago

Doesnt seem to connect to treadmill at all, although the BT LED does light up on the tread when the app starts.. The very first time I tried it, I was also getting pops in the treadmill's speaker randomly -- which happened one other time a week or so ago when we were trying code changes. I'll send you that debug log (the first one) as well as the most recent one. The most recent one, I tried using the Start button a few times - no response from treadmill.

Also - on a somewhat related note -- if I think I understand you correctly, the profiles in QZ will be used at some point to select the treadmill user... But at least on my Pi, elements of the profile UI do not appear when I try them (even though they work on the current iOS app) -- specifically the profile names where you can select dont appear on the Pi. I think the Qt UI has some issues on at least my Pi in this regard - I get similar issues when trying to Open a GPX on the Pi, where the UI doesnt render the filenames correctly.. Is this issue something youve seen before? I dont want to take this off on a tangent right now if its not important at the moment.

debug-Wed_Sep_14_06_46_36_2022.log.txt debug-Wed_Sep_14_07_01_19_2022.log.txt

cagnulein commented 2 years ago

Also - on a somewhat related note -- if I think I understand you correctly, the profiles in QZ will be used at some point to select the treadmill user...

no it's not what I did. What I tried to do on this commit was to remove completely the configuration of the profiles on the treadmill in order to speed up the communication and to leave the profiles as they were.

Unfortunately it seems that the treadmill firmware need them strictly in order to go on. I'm still checking the log in order to think about a possible solution. Otherwise we will go adding the profiles as was the original idea.

So no, you don't have any issue in the UI :)

I will keep you posted

RickNY commented 2 years ago

OK.. Yeah, even in their official app - there is an hourglass the first 45-60 seconds when you open it as it sends the profiles to the treadmill.

cagnulein commented 2 years ago

ok so i'm putting the bases for adding the profiles as well. More than the name which other settings are sent to the treadmill? for example, if you use the qz app on ios, the first user "Guest" has some other attributes? Or it's just simply the name? If it has attributes, could you tell me the values of them so I can parse it in the hexadecimal snoof. Thanks

RickNY commented 2 years ago

ok so i'm putting the bases for adding the profiles as well. More than the name which other settings are sent to the treadmill? for example, if you use the qz app on ios, the first user "Guest" has some other attributes? Or it's just simply the name? If it has attributes, could you tell me the values of them so I can parse it in the hexadecimal snoof. Thanks

So -- on the treadmill itself -- when you power on, it asks you to select user.. Guest is one... The other ones default to "User 1" through "User 5". On the treadmill -- selecting any of these only allows you to then enter weight for that user, remembering the previously entered value. FOR THE APP -- it collects the following info for all the user- Name, Age in years (prompting for date of birth), Weight, Gender. It also allows each user to select US or Metric measurements. I have no idea if any of the attributes other than "Name" and "Weight" get sent to the treadmill. afg_app

cagnulein commented 2 years ago

thanks @RickNY this is exaclty what i need. I will bring these information to the settings. The first try will be changing the default QZ profiles with some one hardcoded, just to check if I can write them freely.

cagnulein commented 2 years ago

checking the last hci snoof log that you sent me, i only see your name, but not weight, gender or age. I guess the app keeps them.

So I'm about to commit a version where I will send the setting "nickname" (already available in QZ) for all the users. If it works, I will add the separate settings.

cagnulein commented 2 years ago

done @RickNY What I did is:

  1. profiles restored in the init phase
  2. nickname setting used for all the profiles. If the nickname is not set, i will use "user"

let me know

RickNY commented 2 years ago

done @RickNY What I did is:

1. profiles restored in the init phase

2. nickname setting used for all the profiles. If the nickname is not set, i will use "user"

let me know

Thanks, Ill try this when I get home from work.. Really, I think the only usefulness for this is for those household members that are just hopping on the treadmill and using it standalone without QZ, etc -- and not being presented with the names that QZ was overwriting each time it was run.

cagnulein commented 2 years ago

Thanks, Ill try this when I get home from work.. Really, I think the only usefulness for this is for those household members that are just hopping on the treadmill and using it standalone without QZ, etc -- and not being presented with the names that QZ was overwriting each time it was run.

Agree :)

RickNY commented 2 years ago

Sorry, was busy past couple of mornings... Tested this now. Below is what I found: 1) After waiting around a minute after app start, pressed Start button in app -- no response from treadmill until appx 20 seconds later when it started 2) Never received speed or status back in app. Stop button did not stop..

Also -- anything that needs to be tested in regards to profiles -- we need to fix the UI in Pi so I can see them. It does not display the list as I mentioned. Im assuming nothing has been changed yet with the profiles because that list of users is still there (Aian, etc) after QZ has connected, so Im assuming its not being overwritten.

debug-Fri_Sep_16_07_30_37_2022.log.txt profiles_1 profiles2

cagnulein commented 2 years ago

Sorry, was busy past couple of mornings... Tested this now. Below is what I found:

  1. After waiting around a minute after app start, pressed Start button in app -- no response from treadmill until appx 20 seconds later when it started
  2. Never received speed or status back in app. Stop button did not stop..

@RickNY thanks, fixed! pull it and build it as usual :)

Also -- anything that needs to be tested in regards to profiles -- we need to fix the UI in Pi so I can see them. It does not display the list as I mentioned. Im assuming nothing has been changed yet with the profiles because that list of users is still there (Aian, etc) after QZ has connected, so Im assuming its not being overwritten.

no there is a misunderstanding :) that one is not the profiles UI that I will use :) That one is the profile UI in order to have different profiles for QZ :) For the horizon treadmill profiles I will create a subUI in the current QZ settings. I will show you it, when I will be ready (probably tomorrow if we will fix the last issue )

Let me know

cagnulein commented 2 years ago

@RickNY i just did another commit, i forgot a thing

RickNY commented 2 years ago

Still no response from tread debug-Fri_Sep_16_18_40_24_2022.log.txt

cagnulein commented 2 years ago

@RickNY did you try several times? because it seems a different issue (similar to https://github.com/cagnulein/qdomyos-zwift/issues/923#issuecomment-1245347671 ). if this commit is never working, ok i will deeply check the log. otherwise i guess it's a desync issue that we need to understand later

RickNY commented 2 years ago

OK, had time to try again.. This time, Start button did nothing - I tried 5 times. However, when I pressed STOP button in App, tread started up and app brought me to graph screen. Here is log from that debug-Mon_Sep_19_17_59_44_2022.log.txt

RickNY commented 2 years ago

Here is a 2nd attempt.. This time, I started the treadmill manually before starting QZ. At no point in this run did QZ show the speed of the treadmill -- however at various times (randomly) the start/pause button in QZ would pause or stop the treadmill. debug-Mon_Sep_19_18_04_33_2022.log.txt