cagnulein / qdomyos-zwift

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

Domyos connected cyclette (E-Fold) #22

Closed cagnulein closed 3 years ago

cagnulein commented 4 years ago

@alpat59 let's continue here đź‘Ť

alpat59 commented 4 years ago

Thank you Roberto. As you know, zWift has a wide adoption in the bikers community, so I think that extending your nice project to those devices could be really appreciated. I’ll support your enhancement development and I confirm you my availability to collaborate and test the code, if needed. At the same time, I kindly ask you some few hints to run your code on Mac (ca I follow the same install instructions for Rpi?) Thank you

cagnulein commented 4 years ago

ok, so first of all you have to following the same steps that i described #15 to collect the packets from the cyclette. About the Mac installation: download this http://download.qt.io/official_releases/qt/5.12/5.12.9/qt-opensource-mac-x64-5.12.9.dmg and clone my repository. Open my project with qtcreator and simply build it.

I will try the same this weekend on my mac air 2013.

cagnulein commented 4 years ago

@alpat59 any news?

alpat59 commented 4 years ago

Roberto, sorry for my delay ... I saw that the packets collection is bsed on android. I haven't android device. So I was trying to find another way by ios and mac (as documented here: https://www.bluetooth.com/blog/a-new-way-to-debug-iosbluetooth-applications/). I need some time to install prereqs and to try... If I'll bot have success I'll go to find an android device... this means some time more to provide you the packets.. I try to understand something more about bluetooth protocols for sport devices (BLE, ANT+, standard bluetooth,...). Could you pls explain me very briefly how your tool work? Substantially I suppose you convert a protocol in another one. What is using DOmyos ? and what is supported by Zwift? Last question, is a bidirectional interaction ? I mean: will I see in zwift the domyos speed and will zwift send to domyos incline (for treadmills) or resistance (for cyclette) commands? Thank you very much in advance

cagnulein commented 4 years ago

@alpat59 my tool read and write (bidirectionally) info from/to domyos (custom protocol, no docs about it) and expose to zwift a classic fitness machine profile.

Zwift doesn't support (till now) writing to the treadmill, but if in the future they will do it, this tool is already compatible.

In the meanwhile you can play with the gpx import that I introduced in version 0.7

cagnulein commented 4 years ago

@alpat59 for sniffing without an android device you will simply buy a bluetooth dongle and sniff the traffic by wireshark I guess

cagnulein commented 4 years ago

Or buy an android device on ebay for 10€ :D

alpat59 commented 4 years ago

I'll do my best ..! and again thank you for your kindness to support us .. and for the info. I was thinking if with your tool, our device could be supported also by other training app (Rouvy, ..). Zwift support the possibility to connect apple watch. It will be possible also using your tool ?

cagnulein commented 4 years ago

Yes of course, exposing a fitness machine profile can work with all the apps on the market.

Yes adding an apple watch (for heart rate I guess?) Should be very easy. But if you can already connect to zwift is pointless, isn't it?

alpat59 commented 4 years ago

do you think it will be possible to provide a docker version of the tool ?

cagnulein commented 4 years ago

@alpat59 maybe it's faster creating a static executable, I'm already doing for #15

cagnulein commented 4 years ago

@alpat59 i've compiled a version for macos, give it a try! (version 0.8.0 https://github.com/cagnulein/qdomyos-zwift/files/5395765/qdomyos-zwift-macOS-0.8.0.zip ) it works on my macbook air (i tested my intense run with zwift :) )

Yusuf-Demiryurek commented 4 years ago

Hi cagnulein, I have a domyos bike 500 and it would be great if I can use it with zwift :)

I write in this topic because I think e-fold works like bike 500 (I had an e-fold before), they have the same console.

Some features works already with bike 500 without any change: read speed display elapsed time display calories display distance start and stop button

I found: position of cadence(rpm): 9 position of level resistance: 14

for display in bike: cadence: 16 speed: 8

I attached my btsnoop log: what I did: connecting to econnected app 0 - 30 seconds: ~40rpm at resistance 1 30 - 60 seconds: ~60rpm at resistance 1 60 - 90 seconds: ~80rpm at resistance 1 90 - 120 seconds: ~60rpm at resistance 1 120 - 150 seconds: ~60rpm at resistance 2 150 - 180 seconds: ~60rpm at resistance 3 180 - 210 seconds: ~60rpm at resistance 4 210 - 240 seconds: ~60rpm at resistance 5

speeds was between ~15km and ~20km

after, I launched a training from app during 5 minutes that variate resistance level between 1 to 15 (max level), I pedaled at 60 rpm.

I have a few little knowledge in coding, so I did some tries by adapting your script but without succeed to adapt it for that zwfit recognize correct indoor bike data.

btsnoop_hci_domyos_bike500.log

cagnulein commented 4 years ago

Hi @kenands welcome aboard! So you mean that all the connection chain works out of the box? Wow!

Yeah I know why zwift doesn't recognize my script as a bike, it should be easy to adapt.

Give me some days and I will give you a version to test!

Have a nice weekend!

Yusuf-Demiryurek commented 4 years ago

Yes it works :) great job. I can already use zwift with my indoor bike as a treadmill.

I tried with changing 0x2ACD treadmill data characteristic uuid into 0x2AD2 (indoor bike data) and manipulate treadmillprovider function but I don't know wich format and position put the data in 'value'. Zwift see power provider, cadence but in some tries with 0 or incorrect data.

I'm not hurry.

Many thanks ! Have a nice weekend !

cagnulein commented 4 years ago

@kenands the format should be described in these documents: https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=261450 https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=261449 https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=412769 https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=412770

which device you will use as bridge? Raspberry?

Yusuf-Demiryurek commented 4 years ago

Thanks, I will take a look. I use a raspberry pi 4.

alpat59 commented 4 years ago

@cagnulein and @kenands ... thank you for great job... I'm late with the data gathering on my e-folder but I see that your are over that step... If you need more data, I'll give you but I have to arrange a way to obtain an android device (I have only iOS).. if I can help you to test the bridge I'll be happy to do it .. but, sorry for that, I can test only on macOS... I'm sure that in few days we'll have a great product .. Thank you again

cagnulein commented 4 years ago

@alpat59 did you see that I released a macOs version?

alpat59 commented 4 years ago

Yes .. thank you ... I tried to start but I need to install the qt prerequisites. I saw that you published a link to a specific version of qt library. Do I need that or standard version (for mac) will be good? Tks

cagnulein commented 4 years ago

Yes .. thank you ... I tried to start but I need to install the qt prerequisites. I saw that you published a link to a specific version of qt library. Do I need that or standard version (for mac) will be good? Tks

Just install this one http://download.qt.io/official_releases/qt/5.12/5.12.9/qt-opensource-mac-x64-5.12.9.dmg

I'll update the readme đź‘Ť

alpat59 commented 4 years ago

tks

cagnulein commented 4 years ago

@kenands something starts moving :+1: Screenshot_20201018_121545_com zwift zwiftgame

Yusuf-Demiryurek commented 4 years ago

Cool :) if you need more input from me, don't hesitate. Thanks.

cagnulein commented 4 years ago

@kenands did you detect the W in the frames? Did your app shows the Watt? It's mandatory on zwift

Yusuf-Demiryurek commented 4 years ago

Econnect doesn't show Watt but kinomap yes. I think this bike doesn't have watt sensor, apps like kinomap estimate watts from cadence and resistance data but I don't know how :/

cagnulein commented 4 years ago

@kenands ok i will add the math as I did for the run

alpat59 commented 4 years ago

@cagnulein I installed the QT package on my mac and then I launched your compiled 0.8 version. But I'm obtained the following messages. Have you some help for me? Thank you

/Users/Alberto/Downloads/qdomyos-zwift ; exit; Alberto@Albertos-MacBook-Pro ~ % /Users/Alberto/Downloads/qdomyos-zwift ; exit; dyld: Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets Referenced from: /Users/Alberto/Downloads/qdomyos-zwift Reason: image not found zsh: abort /Users/Alberto/Downloads/qdomyos-zwift

[Process completed]

cagnulein commented 4 years ago

@alpat59 very strange. Tomorrow I will looking for the root cause. Can you please try to open qt creator and rebuild from source?

alpat59 commented 4 years ago

ok I'll try

cagnulein commented 4 years ago

@kenands some questions:

  1. on your bike you can write only the resistance (1-15), isn't it?
  2. do you have a heart rate monitor on your bike? is it analogic or bluetooth? on my treadmill is analogic and the treadmill reads it
  3. has your bike the fan?
Yusuf-Demiryurek commented 4 years ago

Hi,

  1. Yes, i can only write resistance and value is between 1 and 15.
  2. Yes I have an analogic heartmoniter on the bike and it's already works with treadmill version of your app (from bike to zwift) :)
  3. My bike doesn't have a fan.

Thanks

alpat59 commented 4 years ago

@cagnulein waiting for @kenands answers, I'll give you answers by my side (e-folder byke) based on the native integration with the only two compatible app (e-domyos connected and kinomap): 1) yes, for sure resistance is applied on bike by app depending by workout you selected 2) my bike allows the use of analogic heartrate belt ... but I'm using apple watch connected (paired) to iphone app (kinomap works in that way) 3) e-folder hasn't fan

Great project! Thank you

cagnulein commented 4 years ago

@alpat59 @kenands do you already have a zwift account? Because i almost finished the implentation (for now i expose only the data to zwift, in the next days i will add the possibility to write the resistance from zwift, if possible) and this evening or tomorrow evening i would like to release an alpha version.

Yusuf-Demiryurek commented 4 years ago

@cagnulein yes I have a zwift account. Good news :) you are fast.

alpat59 commented 4 years ago

I have a Zwift account. But I’m able to support you only on Mac but before I need to fix some installation problem. (I’m sorry because I have few time to dedicate to test but I’ll continue to support you at my best !)

cagnulein commented 4 years ago

@kenands if you are able to compile from source, you can try https://github.com/cagnulein/qdomyos-zwift/commit/91db440047376ffaa4807751f6a7303af39fff01 I didn't test anything so it's up to you. post me the full log and in case of segfault, use gdb to give me a backtrace.

In the next days i will fix the UI for the bike.

Thanks

Yusuf-Demiryurek commented 4 years ago

@cagnulein thanks, ok I will do this night.

Yusuf-Demiryurek commented 4 years ago

@cagnulein , I did a try and it did not work at first time because I have a neigboor that have a domyos bike too ^^ (Domyos-Bike-1627). I replaced: if(device.name().startsWith("Domyos-Bike") by if(device.name().startsWith("Domyos-Bike-1175") in bluetooth.cpp and in domyosbike.cpp. It's not work too, I replaced if(device.name().startsWith("Domyos") by if(device.name().startsWith("Domyosx") in bluetooth.cpp then the connection works with the bridge. I don't know how to use gdb. debug-lun. oct. 19 19:35:46 2020.log Zwift detect power and heart rate but power value was very high at resistance 1 and 80 rpm nearly 2000Watts.

It's a good begin :D

Thanks

cagnulein commented 4 years ago

Hahaha I never thought about 2 machine in the neighborhood :D I will add something to choose your machine :)

Ok for the power, it's totally untested code. You did a great job on debugging!

I will check your log and I will fix the bugs. The bike moves on zwift even if the power was a mess?

Yusuf-Demiryurek commented 4 years ago

Last time I tried it wasn't there, but I will move wednesday :). Maybe someone else coud be has the same case ^^

Many thanks :)

Yes bike moves very fast on zwift :D

cagnulein commented 4 years ago

@cagnulein , I did a try and it did not work at first time because I have a neigboor that have a domyos bike too ^^ (Domyos-Bike-1627). I replaced: if(device.name().startsWith("Domyos-Bike") by if(device.name().startsWith("Domyos-Bike-1175") in bluetooth.cpp and in domyosbike.cpp. It's not work too, I replaced if(device.name().startsWith("Domyos") by if(device.name().startsWith("Domyosx") in bluetooth.cpp then the connection works with the bridge. I don't know how to use gdb. debug-lun. oct. 19 19:35:46 2020.log Zwift detect power and heart rate but power value was very high at resistance 1 and 80 rpm nearly 2000Watts.

It's a good begin :D

Thanks

ok, here we go, another round :) https://github.com/cagnulein/qdomyos-zwift/commit/dc5290ced95e12d285a2ebe527829af633443931

i fix the power bug, i added also a filter for your device, just pass to the argument ./qdomyos-zwift -name Domyos-Bike-1175

Let me know if it works :)

Yusuf-Demiryurek commented 4 years ago

@cagnulein, bike connect to zwift but zwift doesn't see the bridge. debug-lun. oct. 19 23:52:55 2020.log

I think there is a little issue on watt computation, it should be:

    if(currentCadence() < 41)
        return((((watt_cad40_max-watt_cad40_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad40_min);
    else if(currentCadence() < 46)
        return((((watt_cad45_max-watt_cad45_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad45_min);
    else if(currentCadence() < 51)
        return((((watt_cad50_max-watt_cad50_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad50_min);
    else if(currentCadence() < 56)
        return((((watt_cad55_max-watt_cad55_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad55_min);
    else if(currentCadence() < 61)
        return((((watt_cad60_max-watt_cad60_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad60_min);
    else if(currentCadence() < 66)
        return((((watt_cad65_max-watt_cad65_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad65_min);
    else if(currentCadence() < 71)
        return((((watt_cad70_max-watt_cad70_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad70_min);
    else if(currentCadence() < 76)
        return((((watt_cad75_max-watt_cad75_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad75_min);
    else if(currentCadence() < 81)
        return((((watt_cad80_max-watt_cad80_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad80_min);
    else if(currentCadence() < 86)
        return((((watt_cad85_max-watt_cad85_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad85_min);
    else if(currentCadence() < 91)
        return((((watt_cad90_max-watt_cad90_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad90_min);
    else if(currentCadence() < 96)
        return((((watt_cad95_max-watt_cad95_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad95_min);
    else if(currentCadence() < 101)
        return((((watt_cad100_max-watt_cad100_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad100_min);
    else if(currentCadence() < 106)
        return((((watt_cad105_max-watt_cad105_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad105_min);
    else if(currentCadence() < 111)
        return((((watt_cad110_max-watt_cad110_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad110_min);
    else if(currentCadence() < 116)
        return((((watt_cad115_max-watt_cad115_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad115_min);
    else if(currentCadence() < 121)
        return((((watt_cad120_max-watt_cad120_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad120_min);
    else if(currentCadence() < 126)
        return((((watt_cad125_max-watt_cad125_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad125_min);
    else
        return((((watt_cad130_max-watt_cad130_min) / (max_resistance - 1)) * (currentResistance() - 1))+watt_cad130_min);

Thanks again :)

cagnulein commented 4 years ago

@kenands Yes you're right about the computation of the Watt, I will fix it this morning but it's not related to the fact that zwift doesn't see the bridge. Did you try to restart zwift and the bridge? Sometimes zwift on my phone hangs the bluetooth and I need to reboot the phone.

Yusuf-Demiryurek commented 4 years ago

@cagnulein oups :/ I forgot to run as sudo, that's why zwift didn't see the bridge. It's work great, I can play zwift with my bike now :) Zwfit get heart rate data and power data. debug-mar. oct. 20 07:22:10 2020.log

Have a good day. Thanks

alpat59 commented 4 years ago

@cagnulein @kenands yesterday night I was able to compile and run code on a raspberry 3 normally used for home domotics. It worked. Not fully stable but it works. I mean that cadence is transferred to zWift (running on Mac) and bike moves. I didn’t test yet the interaction by zWift to Domyos related to resistance writing and changing... is it enabled? Some comments: 1) the installation doc on home got page needs some little fix 2) the tool sometimes goes down 3) I wasn’t able to connect Apple Watch for heart rate (is it still possible, maybe using zWift companion ?) 4) the Domyos console stops to work (@kenands did you see some behavior?)

Anyway, excellent job!!

cagnulein commented 4 years ago

@cagnulein oups :/ I forgot to run as sudo, that's why zwift didn't see the bridge. It's work great, I can play zwift with my bike now :) Zwfit get heart rate data and power data. debug-mar. oct. 20 07:22:10 2020.log

Have a good day. Thanks

great news! I've also fix the watt math https://github.com/cagnulein/qdomyos-zwift/commit/384deeda164467fa9bfb7c0ccef2da41a43ec0ff

cagnulein commented 4 years ago

@cagnulein @kenands yesterday night I was able to compile and run code on a raspberry 3 normally used for home domotics. It worked. Not fully stable but it works. I mean that cadence is transferred to zWift (running on Mac) and bike moves. I didn’t test yet the interaction by zWift to Domyos related to resistance writing and changing... is it enabled?

no, not yet. I want to focus on stabilize the "domyos bike -> zwift" part.

Some comments:

  1. the installation doc on home got page needs some little fix

for example? if you want you could create a pull request yourself for the doc

  1. the tool sometimes goes down

when it happens, send me the log, it's the only way to fix it. Anyway i run several 1h+ session without errors...are you sure about your power supply of the raspberry?

  1. I wasn’t able to connect Apple Watch for heart rate (is it still possible, maybe using zWift companion ?)

As i said, i guess you can connect the apple watch directly to zwift, isn't it?

  1. the Domyos console stops to work (@kenands did you see some behavior?)

in the code i inserted the management of the console (on the treadmill works), i don't know on the bike. @kenands what's on your side?

Anyway, excellent job!!

thanks!

Yusuf-Demiryurek commented 4 years ago

The tool doesn't goes down for me.

For me console displays values but values are at 0 for speed and cadence. The other values seems shown correct data.

I have done few tries with an old treadmill and found positions in the frame for cadence and speed cadence: 16 speed: 8

Thanks

alpat59 commented 4 years ago

I’ll be more precise later on the day. This morning I ran a Zwift workout (on iPhone) for 9 min without any crash and connecting also Apple Watch.