cagnulein / qdomyos-zwift

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

[BUG] Power connects but no signal in Zwift, controllable and cadence not detected #495

Closed r3sonant closed 1 year ago

r3sonant commented 3 years ago

Describe the bug Power connects but shows as no signal in Zwift. Cadence and controllable options don't find anything.

To Reproduce Steps to reproduce the behavior:

  1. Open app.
  2. Power on bike.
  3. App sees and connects to bike.
  4. Open Zwift on tablet.
  5. Attempt to connect to bike.
  6. Power is shown and connected.
  7. Cadence isn't found.
  8. Controllable isn't found.
  9. Power shows as no signal.

Expected behavior Bike is fully connected to Zwift via Qdomyos-zwift app.

Bodytone SMB1v2 Galaxy S8+ Android 9. Galaxy Tab S7 Android 11

debug-Sun_Nov_14_12_15_23_2021.log

cagnulein commented 3 years ago

@r3sonant the problem is this: when QZ brings up the virtual bike interface (the one from zwift), immediately it has a connection from someone/something. So i guess from that point on you will see that issue. ../src/virtualbike.cpp void virtualbike::bikeProvider() "virtual bike connected"

Maybe do you have something around you that tries to connect to an FTMS device by bluetooth? Like bikes/treadmills or other stuff?

I had a case in the past where the bike itself tries to connect to the phone looking for a heart rate device. Maybe is your case too?

r3sonant commented 3 years ago

I can't think what it could be. There aren't any other bikes or treadmills in our flat and I don't think the neighbours have any.

I have a Garmin Fenix 6 and Garmin Connect running on my phone. It's not broadcasting HR or in an activity when I have been testing though.

I have HR2VP installed on my phone but that doesn't look like it's running in the background or as a service.

Thanks.

cagnulein commented 3 years ago

I don't really know because on android there is no way to get the MAC ADDRESS from the sender. I don't have any other way to investigate this deeply from this log. If you want you can try to collect a hci snoof in this scenario and we could investigate more let me know

cagnulein commented 3 years ago

i also adding this email from a user with a similar issue

today i try out my kid device connect to zwift.

oppo cph2219 conected but not sync. log: debug-Mon_Nov_15_10_58_02_2021 (1).log

vivo 1820 conected but not sync log: debug-Mon_Nov_15_07_18_20_2021 (1).log

appo cph 2185 conected but not sync log: debug-Mon_Nov_15_07_40_03_2021.log

samsung SM p355 successfully work and sync. log: debug-Mon_Nov_15_08_24_56_2021.log.zip

i hope this will help you to fix this problem.

cagnulein commented 3 years ago

https://github.com/cagnulein/qdomyos-zwift/issues/495#issuecomment-968687645 about this unfortunately the 3 devices that are not working, have the same behavior of the one of @r3sonant so i guess they cannot have bluetooth peripheral and central at the same time

r3sonant commented 3 years ago

Is this a limitation of the firmware or an early implementation of BLE then do you think?

Is there anyway round it?

I will need to upgrade my phone at some point so was wondering if you have a list of devices confirmed to be working?

I tried again with my Tab S7 and Windows Laptop and that seems to be working now so not sure why it wasn't initially.

The gear or resistance tiles didn't seem to do anything with my bike. I will go through the manual again.

Just out of curiosity. I have a Raspberry Pi 4. I was wondering if I could run QZ as a server on that and use my phone as a client to control it, make the connections etc?

Thanks.

cagnulein commented 3 years ago

Is this a limitation of the firmware or an early implementation of BLE then do you think?

limitation of the firmware

Is there anyway round it?

i guess that some different android ROMs could make some differences...you should try

I will need to upgrade my phone at some point so was wondering if you have a list of devices confirmed to be working?

it's an hard choice on the android world. For QZ a cheap iphone 6s or 7 will be the best!

I tried again with my Tab S7 and Windows Laptop and that seems to be working now so not sure why it wasn't initially.

so maybe the bluetooth stacks needs to be rebooted sometimes?

The gear or resistance tiles didn't seem to do anything with my bike. I will go through the manual again.

i don't know if SMB1 has controlled resistance. Could you manage the resistance from the original Bike's app?

Just out of curiosity. I have a Raspberry Pi 4. I was wondering if I could run QZ as a server on that and use my phone as a client to control it, make the connections etc?

Yes you can, but in order to have a client on the android, you should just use VNC!

Thanks.

r3sonant commented 3 years ago

Hello.

Thanks for the reply.

The SMB1v2 does have controlled resistance, and Zwift controls it OK in free ride mode. I haven't tried since the last Zwift update but workouts didn't work, which is one of the reasons I wanted to get QZ working, in the hope that the bridge would fix the issue.

The other was so I could change gears to effectively go faster downhill or sprint. When pressing the load / resistance button up on the bikes console I can hear the magnet motor making a noise, but I think Zwift overrides it so I don't notice a change.

The gearing or resistance buttons don't seem to do anything when I am connected to Zwift in the free ride mode. I haven't had chance to try in the other modes.

I'm not sure how the gearing option is meant to work, other than that I assumed it would work similar to how a bike with gears on a smart trainer would work.

Thanks.

cagnulein commented 3 years ago

Hello.

Thanks for the reply.

The SMB1v2 does have controlled resistance, and Zwift controls it OK in free ride mode. I haven't tried since the last Zwift update but workouts didn't work, which is one of the reasons I wanted to get QZ working, in the hope that the bridge would fix the issue.

Hah ok, now i got it. Did you enable the erg mode in QZ too? Does qz changes the resistance to your bike if you press the resistance plus/minus button?

The other was so I could change gears to effectively go faster downhill or sprint. When pressing the load / resistance button up on the bikes console I can hear the magnet motor making a noise, but I think Zwift overrides it so I don't notice a change.

The gearing or resistance buttons don't seem to do anything when I am connected to Zwift in the free ride mode. I haven't had chance to try in the other modes.

in order to understand this, i need a debug log with you pressing the plus resistance button without connecting the bike to zwift. just to QZ

I'm not sure how the gearing option is meant to work, other than that I assumed it would work similar to how a bike with gears on a smart trainer would work.

Yes it how it will work :)

Thanks.

r3sonant commented 2 years ago

debug-Sat_Nov_27_12_58_30_2021.log debug-Sat_Nov_27_13_01_09_2021.log

Hi. Here are the logs.

I connected the bike to QZ on my Tab S7 (no Zwift). If I push the resistance buttons on the bikes console the resistance changes and the values are shown in the resistance tile in QZ.

If I push the buttons on the resistance tile or the gear tiles in QZ nothing happens though.

I have tried with erg mode on and off in QZ but it didn't make any difference.

Thanks.

cagnulein commented 2 years ago

@r3sonant i checked the log and there is something strange: if you weren't connected to zwift something else is connected to QZ via the zwift interface. Infact in the log, i saw that there is something connected and so the resistance buttons are inhibited for your bike.

This is the same issue that you have at the beginning of this ticket. What did you do in order to make QZ discoverable by zwift? Did you change the phone?

The only thing that i could do is removing the check of a connection to the virtual bike in order to allow to change the resistance when you want.

r3sonant commented 2 years ago

I was trying to use Bike > Phone > Tablet initially. It's working with Bike > Tablet > Laptop. Although that didn't work at first.

There seems to be a setting that I turn on that brakes it. Not sure what though. I reset the app and it started working again.

I didn't have anything else connected when I generated the log. My phone was on though so I wonder if I have something running on that which is trying to connect to QZ?

cagnulein commented 2 years ago

ok understood, i guess all the issues comes from this ghost connection. Unfortunately android can't tell me which device is connected to it by bluetooth. Do you have a raspberry? or do you wanna try to put the virtual machine of QZ to your laptop with #39 ? In this way we can understand where the issue comes from. What do you think?

r3sonant commented 2 years ago

I have a Raspberry Pi 4.

The Bluetooth didn't seem to work properly when I tried the QZ VM on my laptop. I can try again though.

I was also going to try turning my phone off and generating the logs again from my Tablet in case the phone is interfering. I won't be able to do that until lunchtime or this evening though.

cagnulein commented 2 years ago

i guess your best shot could be the PI4. Did you try to setup it with qz? @r3sonant

r3sonant commented 2 years ago

I haven't done yet. Do you have a link to the process?

Thanks.

cagnulein commented 2 years ago

yeah sure check this https://github.com/cagnulein/qdomyos-zwift/blob/master/docs/10_Installation.md

r3sonant commented 2 years ago

Thank you @cagnulein.

r3sonant commented 2 years ago

Hi @cagnulein,

I'm not sure when I will have the chance to properly play with the Pi install. Probably this weekend. Does it have a web server so I can connect to it and control the features (resistance etc)?

Also, I would like to do some more testing with the tablet to try and track down where the strange ghost connection is coming from.

Where in the logs do you see this connection? I can explore the logs myself then to stop keeping bothering you and let you know what I find.

Thanks again.

cagnulein commented 2 years ago

Hi @cagnulein,

I'm not sure when I will have the chance to properly play with the Pi install. Probably this weekend. Does it have a web server so I can connect to it and control the features (resistance etc)?

You can use VNC bultin to the raspberry!

Also, I would like to do some more testing with the tablet to try and track down where the strange ghost connection is coming from.

ok

Where in the logs do you see this connection? I can explore the logs myself then to stop keeping bothering you and let you know what I find.

here https://github.com/cagnulein/qdomyos-zwift/wiki/How-do-i-get-the-debug-log-in-case-something-doesn't-work%3F

Thanks again.

r3sonant commented 2 years ago

Hi @cagnulein,

Sorry, I meant what line in the logs shows the ghost connection and what can I search for in the log file to find it.

Thanks.

cagnulein commented 2 years ago

hah sorry @r3sonant if you see lines like this

./src/virtualbike.cpp void virtualbike::bikeProvider() "virtual bike connected"

without zwift connected, means that you have a ghost connection.

you should see something over and over

"virtual bike not connected"

r3sonant commented 2 years ago

Thanks @cagnulein.

r3sonant commented 2 years ago

Hi @cagnulein

I've been trying to get QZ up and running on my RPi4 but not having much luck. I installed the latest Raspbian version, but it seems they have removed QT from that, so after some Googling I managed to get that installed, but there were lots of errors from the build. So I installed the legacy Raspbian (Buster based).

I could then build OK, after some more Googling, as there were some commands missing from the instructions (git submodule update --init src/smtpclient/ ).

It ran after the build, but didn't see the bike. Using the -qml switch throws an error about libEGL warning: DRI2: failed to authenticate.

I couldn't see where to raise a bug for that relating to this article (https://github.com/cagnulein/qdomyos-zwift/blob/master/docs/10_Installation.md).

I did generate some more debug logs, attached, using my phone, with the bluetooth on my tablet turned off.

The resistance button still didn't do anything. I tried turning off Zwift Force Resistance and when I tapped the resistance buttons the app crashed.

I don't know if there is anything at all useful in these logs, or if the Zwift Force Resistance has any bearing. I will continue to try and get the RPi up and running.

Thanks. qzlogs.zip

r3sonant commented 2 years ago

Hi @cagnulein

You also mentioned connecting an HCI snoop. Could we try that?

Thanks.

cagnulein commented 2 years ago

Hi @r3sonant i checked your log and

Wed Dec 8 07:57:46 2021 1638950266574 Debug: ../src/virtualbike.cpp void virtualbike::bikeProvider() "virtual bike connected"

at the very beginning i saw this, so the same issue. Are these logs from the raspberry or the phone? if they aren't from the raspberry, could you please attach the one from it?

The HCI snoop have sense if we understand first the virtual bike thing

Let me know

r3sonant commented 2 years ago

Those logs were from my phone.

QZ on the Raspberry won't connect, and won't run with the -qml switch to give me the options.

Here are the logs though from the RPi, it looks like it's finding a stages bike. Could it be hard coded in there?

Thanks. debug-Thu_Dec_9_08_31_16_2021.log

cagnulein commented 2 years ago

@r3sonant because is finding a real Stage device "Found new device: Stages 34886". Is it nearby? could you turn it off? About the -qml what do you see on the screen when you start with -qml? maybe you have to install the qml modules. Try to

apt install -y qml*

r3sonant commented 2 years ago

@cagnulein We don't have a Stages bike, and I don't think our neighbours do either.

I installed the Stages app, it didn't find a Stages bike and also ran nRF Connect and the only bike that found was my Bodytone SMB1 v2.

I remember when I tried the VM that had been locked to a bike, so wondered if this was similar?

I tried apt install -y qml, which installed, I then rebuilt the app but the same error.

_pi@raspberrypi:~/qdomyos-zwift/src $ sudo ./qdomyos-zwift -qml libEGL warning: DRI2: failed to authenticate QStandardPaths: XDG_RUNTIMEDIR not set, defaulting to '/tmp/runtime-root' OK, you are root.

Thanks.

cagnulein commented 2 years ago

@cagnulein We don't have a Stages bike, and I don't think our neighbours do either.

I installed the Stages app, it didn't find a Stages bike and also ran nRF Connect and the only bike that found was my Bodytone SMB1 v2.

because the Pi4 has a bigger bluetooth range so probably is finding something that you can't find with your phone. Consider also that the stages signal could be also a power pedal. Anyway we can workaround this if you can get the QML interface (so you will be able to select a manual device ;) )

I remember when I tried the VM that had been locked to a bike, so wondered if this was similar?

nope it's not the case ;)

I tried apt install -y qml, which installed, I then rebuilt the app but the same error.

are you sure that the command went fine? also are you running from a xorg session on the raspian or from ssh? you need to be on a xorg session with a monitor or VNC

r3sonant commented 2 years ago

Hi @cagnulein

I'm running from an Xorg session over VNC.

The issue I had was with the latest Raspbian OS (based on Debian Bullseye) qt-default has been removed. See below. So I couldn't build QZ.

https://askubuntu.com/questions/1335184/qt5-default-not-in-ubuntu-21-04

I downloaded and installed the legacy version of Raspbian that has recently been released (to address all the issues caused with Bullseye removing things) and was able to build and run the app, but -qml doesn't work.

The error when trying to run with the qml switch, "libEGL warning: DRI2: failed to authenticate" seems to be related to Open GL, but if I change to the Fake KMS GL driver in raspi-config then I am unable to change the resolution when connecting with VNC. It's stuck at super small.

I get the following "sudo ./qdomyos-zwift -qml QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' OK, you are root."

When the GL driver is set to Fake KMS GL driver, but the app doesn't load.

If you know of a Raspberry Pi 4 image that has everything needed and will work I can flash it to the micro SD card and try that.

One other thing, that may or may not be relevant.

The change log here https://github.com/cagnulein/qdomyos-zwift/commit/042bef7fb570a582ae4c530200ff071c35399558

Mentions needing to run git submodule update --init src/qmdnsengine/, but I get "error: pathspec 'src/qmdnsengine/' did not match any file(s) known to git" if I try.

Thanks.

cagnulein commented 2 years ago

@r3sonant the problem is not about the GL driver, that one is just an unreleated warning :) the issue is about QML modules that probably they are not installed. that's why QZ is not starting. That's why i was asking if all the qml modules are ok in my last comment :)

I don't have an image for raspberry because i'm too busy with all the tech assistance around to QZ app ;)

Also ignore the qmdnsengine for now, you don't need it right now.

So please be sure that this command "sudo apt install -y qml*" installed a lot of things with a clean exit state

Let me know

cagnulein commented 2 years ago

also, if you want, we can setup a teamviewer connection, i can setup the image, and then you can upload it here for the other users. what do you think? @r3sonant

r3sonant commented 2 years ago

@cagnulein

"sudo apt install -y qml*" completed without errors or warnings and it looked like there was a lot to install.

I have verified it is installed.

pi@raspberrypi:~ $ dpkg-query -W -f='${Status} ${Version}\n' qml install ok installed 5.11.3-4

Teamviewer sounds like a plan if it would help others as well and the progression of QZ.

Thanks.

cagnulein commented 2 years ago

if you're avaiable on teamviewer we can setup something tomorrow from 8am to 4pm CET. Maybe write me a mail to roberto.viola83 at gmail.com about this I guess we're missing a stupid thing, but i don't remember what :)

Il giorno gio 9 dic 2021 alle ore 20:30 r3sonant @.***> ha scritto:

@cagnulein https://github.com/cagnulein

"sudo apt install -y qml*" completed without errors or warnings and it looked like there was a lot to install.

I have verified it is installed.

@.***:~ $ dpkg-query -W -f='${Status} ${Version}\n' qml install ok installed 5.11.3-4

Teamviewer sounds like a plan if it would help others as well and the progression of QZ.

Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cagnulein/qdomyos-zwift/issues/495#issuecomment-990165542, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWFF5F445DR5UFIAZL3UQD7VFANCNFSM5IAGXJAQ .

r3sonant commented 2 years ago

Hello.

I rebuilt the app and ran it and it generated a log. Wouldn't see the bike though.

Here's the log file. debug-Fri_Dec_31_09_58_11_2021.log

Thanks.

cagnulein commented 2 years ago

@r3sonant you have a issue on the bluetooth

BTLE_DBUS::connect() failed "org.bluez.Error.Failed" "Operation already in progress"

reboot your device, i guess it will solve it

r3sonant commented 2 years ago

Hi @cagnulein

A reboot didn't help. Same error in the logs. Why does it mention schwinnic4bike over and over again as well?

BTLE_DBUS::connect() failed "org.freedesktop.DBus.Error.NoReply"

Thanks.

cagnulein commented 2 years ago

so strange, @r3sonant please try to bisect (or just rollback to a few commits) to check where this starts Thanks

cagnulein commented 2 years ago

hi @r3sonant any news on this?

r3sonant commented 2 years ago

Hi @cagnulein.

I built 2.7 and the Bluetooth is working again. It's still not connecting to the bike though.

Here is a log from just trying.

debug-Wed_Jan_12_19_02_53_2022.log

Sorry for the delay in getting back to you.

Thanks.

cagnulein commented 2 years ago

@r3sonant maybe it's possibile that you're building with the macro TEST enabled? Anyway remove these lines just to try this out (remove the all content inside the ifdef endif) https://github.com/cagnulein/qdomyos-zwift/blob/0aa0ea4614b98c52e74b453c7b2eb620fbc41827/src/bluetooth.cpp#L45

r3sonant commented 2 years ago

Hi @cagnulein.

schwinnIC4Bike = (schwinnic4bike *)new bike();

doesn't appear in bluetooth.cpp in the qdomyos-zwift-2.7 code that I built from.

When I cloned the latest the bluetooth didn't work at all.

Shall I try getting the latest then removing that line?

Thanks.

cagnulein commented 2 years ago

yeah please just do a fresh clone of the repo and build. Maybe it's just a problem of your build folder

Il giorno gio 13 gen 2022 alle ore 19:30 r3sonant @.***> ha scritto:

Hi @cagnulein https://github.com/cagnulein.

schwinnIC4Bike = (schwinnic4bike *)new bike();

doesn't appear in bluetooth.cpp in the qdomyos-zwift-2.7 code that I built from.

When I cloned the latest the bluetooth didn't work at all.

Shall I try getting the latest then removing that line?

Thanks.

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

r3sonant commented 2 years ago

Hi @cagnulein

I deleted the existing QZ folder and did a fresh clone and built it.

It didn't connect to my bike.

Here is the debug log file.

Thanks. debug-Thu_Jan_13_19_27_20_2022.log

cagnulein commented 2 years ago

got the problem, it was about https://github.com/cagnulein/qdomyos-zwift/commit/48e5b219bf74ee29cf022c4b1e9c2c941cb4b679 i'm fixing it

cagnulein commented 2 years ago

done @r3sonant pull and build and try. Let me know!

r3sonant commented 2 years ago

Hi @cagnulein

Progress. I pulled the latest code and built it again.

This time the bike said connected via Bluetooth (it just shows Bluetooth on the console) when I started QZ. QZ didn't go to the tiles screen though and still just showed the searching screen (connecting?).

Here's the log file from that though. debug-Fri_Jan_14_12_34_35_2022.log

Thanks.

cagnulein commented 2 years ago

@r3sonant yeah that's a known bug on linux, check this https://github.com/cagnulein/qdomyos-zwift/issues/422#issuecomment-895196700

r3sonant commented 2 years ago

Hi @cagnulein

So adding deviceConnected(); should fix it?

Should it still be after line 284? The post was from August last year so I thought the code might have changed since then.

image

Thanks.