cagnulein / qdomyos-zwift

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

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

Closed RickNY closed 1 year ago

RickNY commented 1 year 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

cagnulein commented 1 year ago

Thanks @RickNY So that's my plan 1) I will create a new branch for your treadmill where we will try together to fix this issue. 2) every time I will do a modification, you will have to build it (the process will be very fast after the first time) and sending the debug log we will understand together if it's the right path or not.

I will start this afternoon if the baby will get me some sleep :)

cagnulein commented 1 year ago

ok @RickNY first commit done

so do this

  1. git pull
  2. git checkout horizontreadmill7_4
  3. make -j2
  4. run it and tell me if still start at it own
  5. share the debug log

let me know

RickNY commented 1 year ago

OK, with that change, the UI just shows "Connecting...", but doesn't ever show it connected to the Horizon -- however, the BT LED on the treadmill DOES light up. I think due to some sort of bug in Linux though, the connection doesn't break after the program terminates -- on the RPi, I have to toggle bluetooth off for the treadmill's BT light to go out.. Similarly I have to do the same on Debian 11.

The treadmill doesnt start moving automatically -- however, it also doesnt do anything because the app doesnt connect. Log attached. debug-Sat_Sep_3_08_57_18_2022.log.txt

cagnulein commented 1 year ago

@RickNY Thanks but the log seems truncated. Could you please try again and leave qz alive for at least 2 minutes to be safe? Thanks

RickNY commented 1 year ago

Lets try this again.. debug-Sat_Sep_3_09_38_24_2022.log.txt

cagnulein commented 1 year ago

@RickNY Ok perfect! So that frame that I removed it's the start tape frame. So now I would like to put it under the qz start button event. Will be ok to you?

RickNY commented 1 year ago

Not sure I understand -- I can make whatever changes you suggest to get it resolved

RickNY commented 1 year ago

Oh, one thing I just realized -- if I hit the START button in the app, the speed up and incline up buttons will generate a beep on the treadmill -- but nothing actually happens with the treadmill.

cagnulein commented 1 year ago

@RickNY Let me try to explain me better.

The original issue it was the fact that the treadmill started automatically at the connection with QZ.

So what I did in the last commit was to remove the last part of the initialisation.

Your last log confirms that that part starts the treadmill (because now it's not starting anymore)

So my idea is to put this part in the start button event, so after my new modifications you will have to press the qz start button to start the treadmill.

Is it better?

Sorry for my English, but I'm Italian

cagnulein commented 1 year ago

Oh, one thing I just realized -- if I hit the START button in the app, the speed up and incline up buttons will generate a beep on the treadmill -- but nothing actually happens with the treadmill.

Yes because I have to put the start command now ;)

RickNY commented 1 year ago

Understood on both now -- that sounds like its the behavior we would like. Will the "Connecting" thing change to the Horizon text once that change is made?

cagnulein commented 1 year ago

@RickNY Don't mind about the connecting thing, it's just a minor that I have to fix on Linux ;)

cagnulein commented 1 year ago

done @RickNY do a git pull and then a make -j2 and try again let me know

cagnulein commented 1 year ago

@janabouc maybe you're insterested about this thread even if you can't test it right now

janabouc commented 1 year ago

Yes, I'm interested. I think I have had the same issue but I usually don't because I start the tread moving before I connect QZ. That way I can tell when QZ has connected (blue light) AND is registering output (speed is displayed).

It shows blue light always but it takes a minute to get speed displayed. And sometimes I have to reboot QZ to get the output to display.

RickNY commented 1 year ago

OK, so issues on this: 1) The treadmill did not start on its own -- good. 2) The Start button on the app starts the treadmill -- good 3) Incline changes seem to work correctly up and down 4) Speed changes are very inconsistent. Clicking the + or - button in the app will always cause the treadmill to beep -- but will not always change the speed. Even more peculiar is that when it does change the speed, it does in increments that dont match the setting. 5) The first log and test I did was with km/h set as the default.. I changed it to what I would normally use - mph and restarted the app. However -- it took numerous attempts of opening/closing the app before the treadmill would actually start with the new settings. Oddly enough - once it did, the speed buttons worked correctly. 6) Pressing stop in the app does not change anything on the treadmill - it keeps running at the last speed. I dont know if that is expected or if it should do a slow stop. At any rate, if I was on the treadmill I could press the stop button there.

Im attaching a few logs here -- the earliest one was the test with kmh. The others will be additional logs once I had changed the setting to mph. The latest one will be when it successfully started with mph. debug-Sat_Sep_3_10_49_08_2022.log.txt debug-Sat_Sep_3_11_03_18_2022.log.txt debug-Sat_Sep_3_11_04_05_2022.log.txt debug-Sat_Sep_3_11_05_27_2022.log.txt debug-Sat_Sep_3_11_08_40_2022.log.txt debug-Sat_Sep_3_11_11_08_2022.log.txt

RickNY commented 1 year ago

Also, restarting the app after changing an option (in this case - changing the speed step) also appears to not connect back to the treadmill again when it restarts.. At least the BT LED on the treadmill comes back on - but pressing the Start button in the app does nothing.

debug-Sat_Sep_3_11_30_02_2022.log.txt

RickNY commented 1 year ago

Apologies for the multiple comments - one other thing I forgot to add -- when the start button does work and the treadmill starts - it creates an issue that Jana had brought up in her original bug report -- it sets the workout time to 30 minutes, and starts to count down -- when it gets to the end it will stop the workout, which isnt desirable. Can we default that to 99 minutes (which I believe is the max you can set) -- if you can get away with it starting with no set workout time as an available option, that would be even better.

janabouc commented 1 year ago

The only way I’ve found to do a time-unlimited run on my 7.0 is to turn it on and disregard the the start up routine and just push start on the treadmill. Then it will run until I turn it off.

I would prefer to control the treadmill’s starting and stopping on the treadmill, not on QZ because

  1. sometimes I do some walking before I start QZ and the Peloton workout.
  2. Peloton workouts have a 1 minute intro and I like walk during the intro and then push start on QZ to start tracking the workout when the intro finishes.

On Sat, Sep 3, 2022 at 8:44 AM RickNY @.***> wrote:

Apologies for the multiple comments - one other thing I forgot to add -- when the start button does work and the treadmill starts - it creates an issue that Jana had brought up in her original bug report -- it sets the workout time to 30 minutes, and starts to count down -- when it gets to the end it will stop the workout, which isnt desirable. Can we default that to 99 minutes (which I believe is the max you can set) -- if you can get away with it starting with no set workout time as an available option, that would be even better.

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/qdomyos-zwift/issues/923#issuecomment-1236146715, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONHDMJPKMYJPM53WZ5UT3TV4NW4PANCNFSM6AAAAAAQDWNBRA . 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 1 year ago

ok thanks for the test @RickNY I will check this tomorrow, it's evening here and baby calls me ;)

cagnulein commented 1 year ago

@RickNY for the 30 minute issue could you try to enable the horizon_treadmill_7_8 setting and restart QZ? let me know if it's better

RickNY commented 1 year ago

OK, the 7.8 setting reverted the behavior on starting from QZ to 99 minutes.. Also -- is it correct that the "Pause" button in the app does not work as expected on Horizon? As I discovered today, it actually issues a stop/end to the treadmill (same as what the stop button does) and resets the stats on the treadmill itself.

I'm with Jana on many of the points she brought up -- I guess when I am testing these code changes, its easier from where I am sitting on the computer to adjust the treadmill through the app. In real life though when Im using the device, I would be controlling everything speed/incline, start/stop, etc - through the treadmill.

cagnulein commented 1 year ago

is it correct that the "Pause" button in the app does not work as expected on Horizon? As I discovered today, it actually issues a stop/end to the treadmill (same as what the stop button does) and resets the stats on the treadmill itself.

@RickNY yes because I have sniffed out only the start and stop command to the treadmill, so I haven't any pause command to send to the treadmill. If you can collect a hci snoof about it I will implement it for sure!

cagnulein commented 1 year ago

@RickNY i checked the speed force issue and it's releated to the "Speed Step:" setting. Since your treadmill wants in miles/h it must be greter than 0.1 mi/h. Could you try to set it 0.1 or better 0.2 and try again?

about the stop is the 7.8 setting fixed also the stop, isn't it?

RickNY commented 1 year ago

is it correct that the "Pause" button in the app does not work as expected on Horizon? As I discovered today, it actually issues a stop/end to the treadmill (same as what the stop button does) and resets the stats on the treadmill itself.

@RickNY yes because I have sniffed out only the start and stop command to the treadmill, so I haven't any pause command to send to the treadmill. If you can collect a hci snoof about it I will implement it for sure!

horizon74.zip

I dont know if this helps you -- here is an iOS snoop from the Horizon AFG Pro app connecting to the tread, sending Start, Pause, and Stop commands.

cagnulein commented 1 year ago

wow are you an ios dev @RickNY ?

RickNY commented 1 year ago

wow are you an ios dev @RickNY ?

Haha -- NO. I just use Xcode from time to time for troubleshooting along with a good sense of how to find things online

cagnulein commented 1 year ago

@RickNY did you press start, then after 7 seconds pause, and after 1 second stop?

RickNY commented 1 year ago

@RickNY did you press start, then after 7 seconds pause, and after 1 second stop?

Yes - that sounds about right

RickNY commented 1 year ago

Let me know if you want me to capture other things -- like user profile info, weight, etc -- although I think that info is sent in the very beginning - because just opening the app and connecting updates those profile names.

cagnulein commented 1 year ago

@RickNY could I ask you to repeat the start pause stop sequence 2 or 3 times in a row, i would like to check the idmessage byte and the checksum byte.

after this, we can focus about the profiles

RickNY commented 1 year ago

@RickNY could I ask you to repeat the start pause stop sequence 2 or 3 times in a row, i would like to check the idmessage byte and the checksum byte.

after this, we can focus about the profiles

OK.. Here is Start, Pause, Stop three times in a row after the initial connection. Dont know if this is relevant but after each Start there a 3 second countdown before the tread starts. horizon74_2a.zip

cagnulein commented 1 year ago

got the pause frame, i'm implementing it!

55aa120003030100f0e100

cagnulein commented 1 year ago

done @RickNY pull it and build it. let me know if the pause now works ;) thanks for the help

RickNY commented 1 year ago

OK, done... The pause button still is stopping the treadmill and returning it to the "Select User" screen and resetting the session. There continues to be very inconsistent behavior with the initial connection to the treadmill -- and I can't tell when the app has connected or not and is ready to communicate until either the speed starts appearing in the app (if the treadmill was started prior to opening the app) or if using the Start button within the app. In either case, it seems to take multiple presses of the start button. The app since you made the change to keep it from starting automatically continues to just say "Connecting..." after it has started receiving data from the treadmill.

I dont know if this is relevant, but here is the flow when using the official Horizon app: 1) Start AFG app 2) An hourglass will appear in the Horizon app -- for around 30 seconds while it establishes the connection to the treadmill. I believe during this stage, the app is initiating the connection - and sending the relevant profile info to the treadmill (names, weight, etc in the app) 3) Once the hourglass goes away, there is full communication

Also - in regards to the speed steps -- I already had the speed step set to 0.1 and the "Use miles in UI" option set, but pressing the +/- buttons on speed within the app do as follows: 0.5, 0.8, 1.1, 1.4, 1.7 -- but then pressing the - button it goes from 1.7 to 1.3 to 0.9 to 0.5.

Im attaching two logs -- the earlier log is just the pause behavior. The later log is the speed steps - along with the pause and then stop issued.

1-debug-Mon_Sep_5_10_36_28_2022.log.txt 2-debug-Mon_Sep_5_10_56_43_2022.log.txt

RickNY commented 1 year ago

Also -- I had changed the option to 0.2 as well, and it did those same steps as 0.1

cagnulein commented 1 year ago

1-debug-Mon_Sep_5_10_36_28_2022.log.txt

@RickNY you have to wait at least 1 minute between when you open qz and when you will be able to press something...the init phase it's very log, maybe i need to show something to show you that i'm initing the treadmill. also don't press play and pause fast. give it a 5 seconds in the middle. could you please try it back?

the logic that i added for the pause event is:

cagnulein commented 1 year ago

Also - in regards to the speed steps -- I already had the speed step set to 0.1 and the "Use miles in UI" option set, but pressing the +/- buttons on speed within the app do as follows: 0.5, 0.8, 1.1, 1.4, 1.7 -- but then pressing the - button it goes from 1.7 to 1.3 to 0.9 to 0.5.

yeah that's because QZ use km/h and then it lost a decimal in the conversion. I have to study an easy workaround. Anyway the speed control is working

RickNY commented 1 year ago

OK. Log attached.. Roughly what I did:

1:00 -- Pressed start in app, treadmill started 0.5 MPH 1:30 -- Pressed + speed in app, speed increased to 0.8 MPH 1:45 -- Pressed Pause in app, treadmill stopped/ended and returned to "Select User" 2:07 -- Pressed Start in app again, treadmill just beeped but did not start again

Question -- on the UI +/- buttons for speed, are we sending absolute speed commands to the treadmill? Or are we sending a command similar to "Speed Up"? If you'd like, I can capture BT using the iPad AFG app instead -- as that also allows you to do speed +/- and incline +/- changes within the app while running.

cagnulein commented 1 year ago

Question -- on the UI +/- buttons for speed, are we sending absolute speed commands to the treadmill? Or are we sending a command similar to "Speed Up"?

absolute. no need to collect , it's just a math issue on the conversion. i have to figure out an easy way to fix it. anyway i guess it's a minor since you will not use the plus minus buttons on qz anymore after these debug sessions :)

cagnulein commented 1 year ago

@RickNY i don't see the log

RickNY commented 1 year ago

@RickNY i don't see the log

Asking for a bit much now, aren't we? :) Try this -- I got distracted and pulled away midway through typing the last report. debug-Mon_Sep_5_11_15_11_2022.log.txt

janabouc commented 1 year ago

Showing a "connecting" message/icon would be great! The treadmill shows a blue light immediately but it often takes 45 seconds or more before the speed shows and it doesn't always succeed.

I turn on the tread, push Start on tread, open QZ, set the countdown timer on my Apple Watch and if it gets to 1 minute without displaying speed, I reboot QZ and try again. Sometimes it works first try, sometimes it takes 2-3 attempts.

cagnulein commented 1 year ago

Showing a "connecting" message/icon would be great! The treadmill shows a blue light immediately but it often takes 45 seconds or more before the speed shows and it doesn't always succeed.

I turn on the tread, push Start on tread, open QZ, set the countdown timer on my Apple Watch and if it gets to 1 minute without displaying speed, I reboot QZ and try again. Sometimes it works first try, sometimes it takes 2-3 attempts.

yes probably replacing the connecting label with a "hold on, qz is initing your treadmill..." or something

cagnulein commented 1 year ago

@RickNY i don't see the log

Asking for a bit much now, aren't we? :) Try this -- I got distracted and pulled away midway through typing the last report.

debug-Mon_Sep_5_11_15_11_2022.log.txt

thanks, i will check tomorrow, almost dinner time here :)

RickNY commented 1 year ago

Showing a "connecting" message/icon would be great! The treadmill shows a blue light immediately but it often takes 45 seconds or more before the speed shows and it doesn't always succeed. I turn on the tread, push Start on tread, open QZ, set the countdown timer on my Apple Watch and if it gets to 1 minute without displaying speed, I reboot QZ and try again. Sometimes it works first try, sometimes it takes 2-3 attempts.

yes probably replacing the connecting label with a "hold on, qz is initing your treadmill..." or something

So, in these latest builds -- that is kind of there -- QZ is displaying "Connecting..." --- what would be good is when its completed, that it says "Connected" -- OR, does what the current production version of the app does -- display the treadmill name -- but only AFTER the connection is established and ready.

cagnulein commented 1 year ago

@RickNY yes as i told you the connecting thing it's a linux issue

cagnulein commented 1 year ago

@RickNY ok i guess i fixed the pause issue. Please pull it again and build. Thanks

Also, last night, I had an idea about the profiles that will solve also the long delay in the init phase. As soon as we're done with this pause issue, I would like to try to remove the profile writing, and see if the treadmill control could be achievable anyway

One thing at a time, my father always told me :)

RickNY commented 1 year ago

OK, pause button seemed to work on this build.. However, once paused - I was unable to re-start through the app - and pressing start button on tread allowed the tread to resume - but QZ never reconnected after that and updated debug-Tue_Sep_6_07_11_46_2022.log.txt

cagnulein commented 1 year ago

OK.. Here is Start, Pause, Stop three times in a row after the initial connection. Dont know if this is relevant but after each Start there a 3 second countdown before the tread starts. horizon74_2a.zip

@RickNY in this file after the pause, the treadmill restart or it was just pause and then stop? I'm asking this because the treadmill wants a different frame to resume after the pause. If it's so i have to ask to collect another log with

start-pause-start-pause-start-pause-stop

Let me know