cagnulein / qdomyos-zwift

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

QZ Windows version not able to reconnect to Bike's Bluetooth after a windows' cold start #1151

Closed shoulih closed 1 year ago

shoulih commented 1 year ago

Describe the bug QZ Windows version not able to reconnect to Bike's Bluetooth or get bike's data after a windows' cold start

To Reproduce Start the smart bike Pair bike's Bluetooth with the Windows machine Start QZ Windows version and QZ is able to connect and get the bike's data Shutdown the Windows machine and start it after several hours. Start the smart bike Start QZ Windows version, but QZ is not able to connect bike's BT and get the bike's data

Expected behavior QZ Windows version is able to reconnect to Bike's Bluetooth and get bike's data after a windows' cold start

Screenshots

after a cold start

Desktop (please complete the following information):

Append a debug log

[Uploading After a cold start debug-Fri_Jan_13_12_22_53_2023.log…]() Additional context this seems to be the issue according to debug log:

"bluetooth::finished but discoveryAgent is not active"

cagnulein commented 1 year ago

hi @shoulih unfortuantely the log is not fully transfered, could you please add it again? Thanks!

shoulih commented 1 year ago

After a cold start debug-Fri_Jan_13_12_22_53_2023.log

sorry, here is the log file again.

cagnulein commented 1 year ago

thanks @shoulih the problem is Unable to set value for descriptor "{00002902-0000-1000-8000-00805f9b34fb}" for characteristic "{00001535-1412-efde-1523-785feabcd123}" of the service "{00001533-1412-efde-1523-785feabcd123}" : "The semaphore timeout period has expired."

I will try to google this in the next days

shoulih commented 1 year ago

Thanks Robert!

mikemac400 commented 1 year ago

Hey @shoulih , I ran into the same issue and have a workaround while @cagnulein is looking at a fix.

Follow the steps below and you should be able to connect. You need to do this EACH time you want to connect after closing the QZ fitness app.

  1. Go to the windows bluetooth menu and remove the Zwift Hub Device
  2. Restart my computer
  3. Go to the windows bluetooth menu and connect the Zwift Hub Device
  4. Open your QZ fitness app (run as administrator)
  5. Open Zwift

Let me know if this works!

shoulih commented 1 year ago

Hi @mikemac400, thank you for your reply and I use this workaround as well. In my case, I need to remove my bike's Bluetooth and add/pair it back.

Hi @cagnulein did you get a chance to look into the issue, which probably needs to be fixed before releasing it to the Steam store? Thanks!

cagnulein commented 1 year ago

@shoulih zwift hub is his bluetooth device

i'm gonna look at this tomorrow if i can reproduce it on my own

shoulih commented 1 year ago

@cagnulein realized before seeing your comments and updated my reply to @mikemac400

cagnulein commented 1 year ago

ok i'm able to see this myself too.. I'm investigating

Roberto Viola Software engineer and open source enthusiast http://robertoviola.cloud

Il giorno mar 17 gen 2023 alle ore 22:13 shoulih @.***> ha scritto:

@cagnulein https://github.com/cagnulein realized before see your comments and updated my reply to @mikemac400 https://github.com/mikemac400

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

Middy2000 commented 1 year ago

Hi all,

I can confirm that this had normal behaviour with regards to having to unpair the device from BT each time.

You don't to restart Windows however.

I use it for my treadmill and this is how it works.

  1. Start Windows
  2. Unpair device
  3. Run QZ (it will stop at pairing screen)
  4. Pair device

Qz will then pair with your device and then start receiving data. If it fails then you have to quit QZ app before you do anything with the BT Pairing of your device. If you leave QZ running it still will not work. No need to restart Windows.

You could consider writing a batch file to do this for you.

cagnulein commented 1 year ago

since I guess it's a QT windows framework issue, our best shot is using the WSL framework https://www.nextofwindows.com/wslg-is-microsofts-offical-gui-for-wsl2

In this way, the linux version of QZ could run on windows without these bluetooth madness. It's just an idea

cagnulein commented 1 year ago

mm bluetooth on WSL is still missing https://github.com/microsoft/WSL/issues/242 or at least without rebuilding the kernel. I guess the other way to get this is using virtualbox as I did before with https://github.com/cagnulein/qdomyos-zwift/issues/39#issuecomment-722273585

wbjenn commented 1 year ago

Roberto asked me to comment here because I use Zwift almost daily with a Windows 10 set up and the TP Link Bluetooth 4.0 dongle. The only times I have ever had an issue connecting to my EX-3 is after a Windows update. A simple reboot has always done the trick.

The last time this happened was on Sunday (Jan 15th) upon returning from 3 weeks away. Do you use a BT dongle?

shoulih commented 1 year ago

Roberto asked me to comment here because I use Zwift almost daily with a Windows 10 set up and the TP Link Bluetooth 4.0 dongle. The only times I have ever had an issue connecting to my EX-3 is after a Windows update. A simple reboot has always done the trick.

The last time this happened was on Sunday (Jan 15th) upon returning from 3 weeks away. Do you use a BT dongle?

I have an ASUS USB BT500 and will give it a try.

mikemac400 commented 1 year ago

I do not use a bluetooth dongle. Bluetooth is integrated into my PC. It's a Thinkpad P1 Gen 2. Firmware/BIOS are completely up to date according to Lenovo's firmware manager,

mikemac400 commented 1 year ago

@cagnulein - I have attached my debugging log from when my computer connects to the Zwift Hub, but does not receive any power data. Hopefully, this can help you identify whether my issue is the same or different. debug-Wed_Jan_18_18_15_17_2023.log

cagnulein commented 1 year ago

@cagnulein - I have attached my debugging log from when my computer connects to the Zwift Hub, but does not receive any power data. Hopefully, this can help you identify whether my issue is the same or different.

same issue unfortunately. is it possible for you to buy this exact model https://amzn.to/3NyvQRG

it's the @wbjenn one

mikemac400 commented 1 year ago

@cagnulein Ahhh gotcha, so that bluetooth dongle should work? I'm currently using my PC's built-in bluetooth.

cagnulein commented 1 year ago

@mikemac400 usually it performs better but be sure to buy the exactly model as i posted. no bluetooth 5.

but @wbjenn and @Middy2000 have the same dongle but they are experiencing different behaviors so i guess it's also about all the windows blotware around

mikemac400 commented 1 year ago

Sounds good. I can give it a shot, thanks! If it doesn't work, I can always return it since it is Amazon.

Middy2000 commented 1 year ago

I had to purchase the BT adapter that @cagnulein suggested. I had a V5.0 dongle but it wouldn't work.

mikemac400 commented 1 year ago

I purchased the UB-400 dongle today that @cagnulein mentioned here, and QZ fitness now works great! I can close/restart the app multiple times, and the app will read power data from the bike. I am also not seeing any bluetooth error messages in the debug logs.

Note that when you receive the dongle, you will need to disable your internal bluetooth device in "device manager" if you have native bluetooth to the laptop.

shoulih commented 1 year ago

I purchased the UB-400 dongle today that @cagnulein mentioned here, and QZ fitness now works great! I can close/restart the app multiple times, and the app will read power data from the bike. I am also not seeing any bluetooth error messages in the debug logs.

Note that when you receive the dongle, you will need to disable your internal bluetooth device in "device manager" if you have native bluetooth to the laptop.

That is very interesting, but good to know as my ASUS USB BT500 doesn't work.

BTW, can you please confirm it still works after turning off PC and turning it back on in a couple of hours or overnight?

Thanks!

wbjenn commented 1 year ago

I purchased the UB-400 dongle today that @cagnulein mentioned here, and QZ fitness now works great! I can close/restart the app multiple times, and the app will read power data from the bike. I am also not seeing any bluetooth error messages in the debug logs. Note that when you receive the dongle, you will need to disable your internal bluetooth device in "device manager" if you have native bluetooth to the laptop.

That is very interesting, but good to know as my ASUS USB BT500 doesn't work.

BTW, can you please confirm it still works after turning off PC and turning it back on in a couple of hours or overnight?

Thanks!

@shoulih No offense, but the dongle costs $10, @cagnulein told you this was the right dongle to purchase to solve your problem and several users have replied that the dongle works. I responded that the dongle worked after being away for 3 weeks. Please just purchase the dongle and close this ticket. If you need help setting up the dongle, let us know.

shoulih commented 1 year ago

I purchased the UB-400 dongle today that @cagnulein mentioned here, and QZ fitness now works great! I can close/restart the app multiple times, and the app will read power data from the bike. I am also not seeing any bluetooth error messages in the debug logs. Note that when you receive the dongle, you will need to disable your internal bluetooth device in "device manager" if you have native bluetooth to the laptop.

That is very interesting, but good to know as my ASUS USB BT500 doesn't work. BTW, can you please confirm it still works after turning off PC and turning it back on in a couple of hours or overnight? Thanks!

@shoulih No offense, but the dongle costs $10, @cagnulein told you this was the right dongle to purchase to solve your problem and several users have replied that the dongle works. I responded that the dongle worked after being away for 3 weeks. Please just purchase the dongle and close this ticket. If you need help setting up the dongle, let us know.

thank you for the confirmation and my UB-400 will arrive this Saturday.

wbjenn commented 1 year ago

Great! It's pretty much plug and play, so you should be good. Have an excellent workout!

mikemac400 commented 1 year ago

@wbjenn @cagnulein - QZ Works perfectly withe the UB-400 dongle, even after PC restart.

cagnulein commented 1 year ago

@wbjenn @cagnulein - QZ Works perfectly withe the UB-400 dongle, even after PC restart.

wow good news! i guess i should buy 1000 of them before they will go out of production:)

Middy2000 commented 1 year ago

@mikemac400

Do you have to unpair the BT device each time before QZ works or does it work after restarting?

Each time I use Qz I have to unpair my treadmill in Windows before starting QZ otherwise QZ doesn't receive any data from the treadmill. It will pair to the treadmill but not receive data.

mikemac400 commented 1 year ago

@Middy2000 Do you have the UB-400? I do not have to unpair/repair the bike.

I would also recommend you check "device manager" to make sure you are using your dongle and not the bluetooth native to the computer (if you have that). You have to disable the native bluetooth if you have both the dongle and bluetooth on your computer.

Middy2000 commented 1 year ago

Yep I'm using the ub400. I have no native BT.

I work closely with Roberto to test his app on various devices. We're not sure why it has to be unpaired. Possibly Windows is caching the previous connection.

That's why I'm interested in others.

So basically each time you boot up windows and run QZ it works straight away?

mikemac400 commented 1 year ago

@Middy2000 - Yes, it works immediately now. You can try checking that your ub400 driver is up to date using device manager and your windows is up to date (I'm on windows 10).

I have noticed windows doing caching when they shouldn't, completely outside of the QZ fitness app. The most obvious example of this is I can click "forget device" on the Zwift Hub, and the Zwift Hub still says it's connected. When I turn bluetooth off completely, the Zwift Hub disconnects, showing that windows is storing the connection even though it should be forgotten I believe that is why restarting the computer sort of worked before I got the ub400. This could also be an issue in windows "forget device" protocol though as opposed to caching.

cagnulein commented 1 year ago

@Middy2000 @mikemac400 maybe you can compare your driver version?

Middy2000 commented 1 year ago

I'm on Windows 10 & it's all up to date.

I'll look into it more my end, I just believed it to be one of those little mysteries. It's not a huge problem, probably takes 30 seconds to complete the pairing process.

shoulih commented 1 year ago

My UB-400 arrived today; plugged in to my Windows 10 box and disabled the Bluetooth that comes with the machines. QZ works after pairing bike's BT with UB-400, but the same issue after a Windows' cold start several hours later. Please find the debug log, screen shot of Bluetooth device and QZ for Windows version number:

BlueTooth QZ_version debug-Sat_Jan_21_23_07_01_2023.log

Middy2000 commented 1 year ago

@shoulih

Does it work if you use the procedure I described above that I have to do?

shoulih commented 1 year ago

@shoulih

Does it work if you use the procedure I described above that I have to do?

yes for UB-400, which also works for the Bluetooth device that comes with my Windows 10 box.

Middy2000 commented 1 year ago

How strange that for done it works fine but others it doesn't. I experimented today but nothing I did changed anything. I still have to unpair each time.

cagnulein commented 1 year ago

@Middy2000 as i said, you should to compare your driver versions

shoulih commented 1 year ago

what is the QZ for Windows version you guys are using, especially for those who don't have to unpair/repair with the UB-400?

mikemac400 commented 1 year ago

@Middy2000 @shoulih @cagnulein - I've been using the QZ app for a few days now, and had to pair/unpair for the first time. HOWEVER... I believe the culprit was actually my Zwift hub (indoor bike) device. It was saying it was "paired" even though my bluetooth was turned off completely. Maybe a neighbor paired to it or something... who knows. I just unplugged it and plugged it back in and it paired first try with the UB-400.

I am using the drivers that were installed by default. You can always check that your drivers are up to date by using device manager. The exact version I am on is below.

image image

I also have the "virtual device" setting turned off in the QZ app. This is in "experimental settings". image

shoulih commented 1 year ago

to me that UB-400 makes no differences in terms of making QZ for Windows work again after a cold start (i.e. have to unpair/repair) . I also have the "Virtual Device Blue" setting turned off in the QZ for Windows; will that cause the different behaviors? Look like I still can't decommission QZ on Raspberry Pi yet, but I really want to run both QZ and Zwift on a single Windows 10 box.

Middy2000 commented 1 year ago

I'm using this version 20230126_084314

I'm running 2.12.3 version of QZ

shoulih commented 1 year ago

I'm using this version 20230126_084314

I'm running 2.12.3 version of QZ

Thanks for your reply and we are using the same version of driver for UB-400, but you are using the earlier version of QZ for Windows.

@cagnulein how can I download the 2.12.3 version of QZ for Windows to test with UB-400?

cagnulein commented 1 year ago

@shoulih i don't think that version is already available because github delete it after some weeks. you have to browse here https://github.com/cagnulein/qdomyos-zwift/actions?page=10 using the older button to get a version in that window time

let me know if you don't get it

Middy2000 commented 1 year ago

I doubt the difference in we versions is making any difference. I'm convinced it's my treadmill. It does strange things when linked to qz. If I stop the treadmill once connected all the buttons on the treadmill stop responding unless I turn it off and on again.

cagnulein commented 1 year ago

I doubt the difference in we versions is making any difference.

yes i think so too

I'm convinced it's my treadmill. It does strange things when linked to qz. If I stop the treadmill once connected all the buttons on the treadmill stop responding unless I turn it off and on again.

could be probably, yes

shoulih commented 1 year ago

@mikemac400 @wbjenn what version of QZ for Windows you guys are using that doesn't require you "unpair/repair" every time with UB-400?

wbjenn commented 1 year ago

@mikemac400 @wbjenn what version of QZ for Windows you guys are using that doesn't require you "unpair/repair" every time with UB-400?

@shoulih I'm using QZ Windows version 2.10.80. Zwift just rolled out an update (it's giving some Kickr users fits) yesterday.

I can report no problems connecting after the update. I did some badge hunting and completed The Mega Pretzel in a little less than 4 hours. No drops and I even paused Zwift and QZ to replenish my water supplies.

shoulih commented 1 year ago

@mikemac400 @wbjenn what version of QZ for Windows you guys are using that doesn't require you "unpair/repair" every time with UB-400?

@shoulih I'm using QZ Windows version 2.10.80. Zwift just rolled out an update (it's giving some Kickr users fits) yesterday.

I can report no problems connecting after the update. I did some badge hunting and completed The Mega Pretzel in a little less than 4 hours. No drops and I even paused Zwift and QZ to replenish my water supplies.

thanks for the update!