cagnulein / QZCompanionNordictrackTreadmill

Companion App of QZ for Nordictrack Treadmills and Bikes
https://www.qzfitness.com/
GNU Affero General Public License v3.0
44 stars 12 forks source link

No connection to x22i #65

Closed samkenw closed 8 months ago

samkenw commented 10 months ago

Hi there,

Trying to get this to run with my Nordictrack x22i.

What I did: Installed companion via browser (no windows pc available). In the companion app I selected "other". In the QZ app (iOS) added the IP address of the treadmill.

Issue: In the iOS app I am seeing the data fields - but nothing is changing.

Logs: In the log dump in the companion app on the treadmill I get:

2023-11-03 17:59:18.755 Service started 2023-11-03 17:59:18.765 Service onCreate 2023-11-03 17:59:18.765 Service postDelayed 2023-11-03 17:59:18.766 Service started 2023-11-03 17:59:19.267 Service run 2023-11-03 17:59:19.276 /sdcard/.wolflogs/ 2023-11-03 17:59:19.276 lastModifiedFile /scard/wolflogs/2023-11-03 _logs.txt 2023-11-03 17:59:19.277 string: /sdeard/wolflogs/2023-11-03_logs.txt 2023-11-03 17:59:19.277 Parsing /sdcard/.wolflogs/2023-11-03_logs.txt 2023-11-03 17:59:19.278 Device: null 2023-11-03 17:59:19.654 2023-11-03 17:59:19.894 2023-11-03 17:59:19.936 Got UDP broadcast from , message: -1;-100 2023-11-03 17:59:19.937 -1:-100

cagnulein commented 10 months ago

Which treadmill would I need to select? The x22i is not an option.

the ip is enough, the device is selected in the companion

samkenw commented 10 months ago

Is this not the message received from the app? Seems like the app is broadcasting the wrong values?

2023-11-05 12:53:00.028 Got UDP broadcast from ip, message: -1;-100 2023-11-05 12:53:00.031 -1;-100 2023-11-05 12:53:00.035 requestSpeed: -1.0 lastSpeed:3.0 cachedSpeed:-1.0 2023-11-05 12:53:00.038 requestInclination: -100.0 -100.0

cagnulein commented 10 months ago

as i said qz is always sending those values. when it has a request from the user it change -1 to the value that you request.

so you have to capture the right moment in the log or simply send me logcat file available in the root of the tablet so i can check the whole file myself

Let me know

Il giorno dom 5 nov 2023 alle 13:05 Sam K @.***> ha scritto:

Is this not the message received from the app? Seems like the app is broadcasting the wrong values?

2023-11-05 12:53:00.028 Got UDP broadcast from 192.168.178.21, message: -1;-100 2023-11-05 12:53:00.031 -1;-100 2023-11-05 12:53:00.035 requestSpeed: -1.0 lastSpeed:3.0 cachedSpeed:-1.0 2023-11-05 12:53:00.038 requestInclination: -100.0 -100.0

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793717857, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWB47F4CACHEHLR6QELYC56IVAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG4YTOOBVG4 . You are receiving this because you commented.Message ID: @.*** com>

samkenw commented 10 months ago

Ah I understand, sorry.

Here is a request: 2023-11-05 13:16:11.932 (43] 4126844 13:05:31.1260 [Trace:FitPro) Changed Watts to: 0 2023-11-05 13:16:12.036 Got UDP broadcast from ip, message: 0.5;-100 2023-11-05 13:16:12.036 0.5;-100 2023-11-05 13:16:12.037 requestSpeed: 0.5 lastSpeed:0.0 cachedSpeed:-1.0 2023-11-05 13:16:12.037 requestinclination: -100.0 -100.0 2023-11-05 13:16:12.04 Waiting for UDP broadcast 2023-11-05 13:16:12.043 Got UDP broadcast from ip, message: -1;-100 2023-11-05 13:16:12.044 -1;-100 2023-11-05 13:16:12.044 requestSpeed: -1.0 lastSpeed:0.0 cachedSpeed:0.5 2023-11-05 13:16:12.045 requestInclination: -100.0 -100.0

cagnulein commented 10 months ago

perfect! the reason why it's not working it's because qz companion wants to see a speed greater than 0 to send the touch event.

try to start the treadmill to a speed of 1 for example, wait qz to shows it, and then try to change it

let me know

Il giorno dom 5 nov 2023 alle 13:19 Sam K @.***> ha scritto:

Ah I understand, sorry.

Here is a request: 2023-11-05 13:16:11.932 (43] 4126844 13:05:31.1260 [Trace:FitPro) Changed Watts to: 0 2023-11-05 13:16:12.036 Got UDP broadcast from 192.168.178.21, message: 0.5;-100 2023-11-05 13:16:12.036 0.5;-100 2023-11-05 13:16:12.037 requestSpeed: 0.5 lastSpeed:0.0 cachedSpeed:-1.0 2023-11-05 13:16:12.037 requestinclination: -100.0 -100.0 2023-11-05 13:16:12.04 Waiting for UDP broadcast 2023-11-05 13:16:12.043 Got UDP broadcast from 192.168.178.21, message: -1;-100 2023-11-05 13:16:12.044 -1;-100 2023-11-05 13:16:12.044 requestSpeed: -1.0 lastSpeed:0.0 cachedSpeed:0.5 2023-11-05 13:16:12.045 requestInclination: -100.0 -100.0

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793721289, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWCGIYXRI463PDUV7MLYC576VAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG4ZDCMRYHE . You are receiving this because you commented.Message ID: @.*** com>

samkenw commented 10 months ago

Alright, now with a running treadmill and set to c1750:

2023-11-05 12:35:23.727 Parsing /sdcard/wolflogs/2023-11-05_logs.txt 2023-11-05 12:35:23.729 Device: c1750 2023-11-05 12:35:24.009 (7] 379869 12:34:54.4954 [Trace:DemoModeServiceSelector] Changed KPH to: 2 2023-11-05 12:35:24.011 [7] 197746 12:31:52.3710 [Trace:RetailDemoMode1ServiceAdapter] Changed Watts to: 107 2023-11-05 12:35:24.045 Got UDP broadcast from ip, message: 2.5;-100 2023-11-05 12:35:24.046 2.5;-100 2023-11-05 12:35:24.046 requestSpeed: 2.5 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-05 12:35:24.048 input swipe 1845 690 1845 706 200 2023-11-05 12:35:24.051 Waiting for UDP broadcast 2023-11-05 12:35:24.514 Service run 2023-11-05 12:35:24.523 /sdcard/wolflogs/ 2023-11-05 12:35:24.525 lastModifiedFile /sdcard/wolflogs/2023-11-05_logs.txt

cagnulein commented 10 months ago

perfect now but you have to use the x22i device in the companion that i created for you and remember to reboot the treadmill

Il giorno dom 5 nov 2023 alle 13:33 Sam K @.***> ha scritto:

Alright, now with a running treadmill and set to c1750:

2023-11-05 12:35:23.727 Parsing /sdcard/wolflogs/2023-11-05_logs.txt 2023-11-05 12:35:23.729 Device: c1750 2023-11-05 12:35:24.009 (7] 379869 12:34:54.4954 [Trace:DemoModeServiceSelector] Changed KPH to: 2 2023-11-05 12:35:24.011 [7] 197746 12:31:52.3710 [Trace:RetailDemoMode1ServiceAdapter] Changed Watts to: 107 2023-11-05 12:35:24.045 Got UDP broadcast from 192.168.178.21, message: 2.5;-100 2023-11-05 12:35:24.046 2.5;-100 2023-11-05 12:35:24.046 requestSpeed: 2.5 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-05 12:35:24.048 input swipe 1845 690 1845 706 200 2023-11-05 12:35:24.051 Waiting for UDP broadcast 2023-11-05 12:35:24.514 Service run 2023-11-05 12:35:24.523 /sdcard/wolflogs/ 2023-11-05 12:35:24.525 lastModifiedFile /sdcard/wolflogs/2023-11-05_logs.txt

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793724695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWFX5TJJMDIARFV3C4LYC6BTLAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG4ZDINRZGU . You are receiving this because you commented.Message ID: @.*** com>

samkenw commented 10 months ago

I will try but when selecting the x22i there was no feedback in the QZ app. I will try again and let you know.

cagnulein commented 10 months ago

argh you are right! i missed a thing! i will do later today

sorry

Il giorno dom 5 nov 2023 alle 13:42 Sam K @.***> ha scritto:

I will try but when selecting the x22i there was no feedback in the QZ app. I will try again and let you know.

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793726720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWHSLVESKCZB6GCTT6TYC6CUVAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG4ZDMNZSGA . You are receiving this because you commented.Message ID: @.*** com>

samkenw commented 10 months ago

okay great, thanks!

cagnulein commented 10 months ago

done https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.14/QZCompanionNordictrackTreadmill.apk sorry for the issue

samkenw commented 10 months ago

Great! Now seeing the changes in the QZ app. However, no input events seen when changing the values.

Log Dump: 2023-11-05 16:19:42.003 Parsing /scard/wolflogs/2023-11-05 _logs.txt 2023-11-05 16:19:42.014 Device: x221 2023-11-05 16:19:42.396 [20] 365957 16:17:55.8296 [Trace:FitPro] Changed KPH to: 2 2023-11-05 16:19:42.399 [10] 366875 16:17:56.7470 [Trace:FitPro] Changed Watts to: 107 2023-11-05 16:19:42.438 Got UDP broadcast from ip, message: -1;0.5 2023-11-05 16:19:42.44-1:0.5 2023-11-05 16:19:42.442 requestSpeed: -1.0 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-05 16:19:42.446 requestinclination: 0.5 - 100.0 2023-11-05 16:19:42.449 input swipe 75 785 75 711 200 2023-11-05 16:19:42.454 Waiting for UDP broadcast 2023-11-05 16:19:42.456 Waiting for UDP broadcast 2023-11-05 16:19:42.905 Service run 2023-11-05 16:19:42.918 /sdcard/wolflogs/ 2023-11-05 16:19:42.923 lastModifiedFile /sdcard/wolflogs/2023-11-05_logs.txt

cagnulein commented 10 months ago

input swipe are now sent correctly. can you check if you can set qz companion as an adb debug app inn the developer setting on the treadmill tablet?

Il giorno dom 5 nov 2023 alle 16:27 Sam K @.***> ha scritto:

Great! Now seeing the changes in the QZ app. However, no input events seen when changing the values.

Log Dump: 2023-11-05 16:19:42.003 Parsing /scard/wolflogs/2023-11-05 _logs.txt 2023-11-05 16:19:42.014 Device: x221 2023-11-05 16:19:42.396 [20] 365957 16:17:55.8296 [Trace:FitPro] Changed KPH to: 2 2023-11-05 16:19:42.399 [10] 366875 16:17:56.7470 [Trace:FitPro] Changed Watts to: 107 2023-11-05 16:19:42.438 Got UDP broadcast from 192.168.178.21, message: -1;0.5 2023-11-05 16:19:42.44-1:0.5 2023-11-05 16:19:42.442 requestSpeed: -1.0 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-05 16:19:42.446 requestinclination: 0.5 - 100.0 2023-11-05 16:19:42.449 input swipe 75 785 75 711 200 2023-11-05 16:19:42.454 Waiting for UDP broadcast 2023-11-05 16:19:42.456 Waiting for UDP broadcast 2023-11-05 16:19:42.905 Service run 2023-11-05 16:19:42.918 /sdcard/wolflogs/ 2023-11-05 16:19:42.923 lastModifiedFile /sdcard/wolflogs/2023-11-05_logs.txt

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793768267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWBG5S5ATTPLI36L2OLYC6V7BAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG43DQMRWG4 . You are receiving this because you commented.Message ID: @.*** com>

samkenw commented 10 months ago

Just tried. Also restart treadmill afterwards. Sadly no success. Can this maybe be the same issue that I can't connect via adb over wifi?

samkenw commented 10 months ago

another thing: each time I restart the treadmill, I have to go back into developer options and enable usb debugging... not sure why this is being turned off again.. perhaps there is some lock on it? (I am on the newest software version)

cagnulein commented 10 months ago

nope it shouldn't be about this because you can with another terminal app. I can try another approach tomorrow We are very near!

Il giorno dom 5 nov 2023 alle 16:40 Sam K @.***> ha scritto:

Just tried. Also restart treadmill afterwards. Sadly no success. Can this maybe be the same issue that I can't connect via adb over wifi?

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/65#issuecomment-1793771443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWGJRV6GI7QG7HTGV63YC6XNXAVCNFSM6AAAAAA64XWWIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTG43TCNBUGM . You are receiving this because you commented.Message ID: @.*** com>

cagnulein commented 10 months ago

another thing: each time I restart the treadmill, I have to go back into developer options and enable usb debugging... not sure why this is being turned off again.. perhaps there is some lock on it? (I am on the newest software version)

yes this is normal on the newer ifit version

samkenw commented 10 months ago

alright, thanks for the effort up to now !

samkenw commented 10 months ago

So, 2 things I noticed yesterday:

  1. It seems that the companion app stops transferring data after a certain point. To fix this, I had to switch to the companion app (bring it to the foreground) and then switch back. Then it was fine again for a while. Could it be that the app is being put to sleep after a while?

  2. I was not getting any heart rate data from the treadmill - is there an easy fix for this?

cagnulein commented 10 months ago
  1. It seems that the companion app stops transferring data after a certain point. To fix this, I had to switch to the companion app (bring it to the foreground) and then switch back. Then it was fine again for a while. Could it be that the app is being put to sleep after a while?

mmm interesting, I never noticed this on others. I can put a notification on the companion so the app will be forced to stay awake. I'm doing the mod today along with the new input swipe thing

2. I was not getting any heart rate data from the treadmill - is there an easy fix for this?

can you open the file /sdcard/wolflogs/2023-11-05 _logs.txt and check if you see the HR there? if so I can parse it for sure!

samkenw commented 10 months ago

Great and great, will check the logs and get back to you!

cagnulein commented 10 months ago

ok i did the input swipe patch. let me know if it's better https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.15/QZCompanionNordictrackTreadmill.apk

samkenw commented 10 months ago

Great, will test it shortly!

This is the line for the heart rate from the logs:

timestamp etc [Trace: HeartRateConnection] HeartRateConnection. HeartRateDataUpdate heart rate value changed. Value: 127 Device: device id

cagnulein commented 10 months ago

perfect! added! for HR you need to update both QZ companion to the 3.3.16 and QZ to the last build, for this send me an email to roberto.viola83 at gmail.com indicating this ticket and if you are on android or iOS. Thanks

samkenw commented 10 months ago

Awesome, thanks! will do!

Sadly, no change on the swipe issue:

  2023-11-06 09:19:41.295 [11) 201742 09:19:24.0759 (Trace:FitPro) Changed KPH to: 2
  2023-11-06 09:19:41.299 41 202849 09:19:25.1835 [Trace:FitPro, Changed Watts to: 107
  2023-11-06 09:19:41.41 Got UDP broadcast from ip address, message: 2.5;100
2023-11-06 09:19:41.416 2.5;-100  
  2023-11-06 09:19:41.424 requestSpeed: 2.5 lastSpeed:2.0 cachedSpeed:-1.0
  2023-11-06 09:19:41.433 requestSpeed: -1.0 lastSpeed:2.0 cachedSpeed:-1.0
cagnulein commented 10 months ago

new companion for the HR https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.16/QZCompanionNordictrackTreadmill.apk

I don't see the input swipe line in your log, could you please post the full log?

samkenw commented 10 months ago

Thanks! There is no further output. If I see correctly, in the shellRuntime.exec there is no logging though, is that correct? Edit: sorry, here is the log:

2023-11-06 09:19:41.41 Got UDP broadcast from ip, message: 2.5;-100 2023-11-06 09:19:41.416 2.5;100 2023-11-06 09:19:41.424 requestSpeed: 2.5 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-06 09:19:41.433 requestSpeed: -1.0 lastSpeed:2.0 cachedSpeed:-1.0 2023-11-06 09:19:41.46 requestInclination: -100.0 -100.0 2023-11-06 09:19:41.469 Waiting for UDP broadcast 2023-11-06 09:19:41.474 input swipe 1845 725 1845 725 200 2023-11-06 09:19:41.483 Waiting for UDP broadcast

I also activated the "show pointer" option - so even if the coordinates should be wrong, we should be seeing something.

cagnulein commented 10 months ago

yes but on line 280 there is a writeLog(command);

samkenw commented 10 months ago

My bad, updated previous comment.

cagnulein commented 10 months ago

ok so there is the input swipe. could you run that exactly line in the terminal to check that you can see the swipe from the terminal?

samkenw commented 10 months ago

This is returning "killed" in the terminal

cagnulein commented 10 months ago

interesting, so what's the difference from the one that worked before?

samkenw commented 10 months ago

trying to figure that out.. the other one still works

cagnulein commented 10 months ago

can you put here the one that it's working?

also try to change one by one the parameters so we will quickly understand which is the issue :)

We're so near!

samkenw commented 10 months ago

input swipe 1845 200 1845 400 200 works input swipe 1845 725 1845 525 200 fails :D

will do some testing and get back

samkenw commented 10 months ago

Alright so: input swipe 1845 650 1845 650 200 works input swipe 1845 680 1845 680 200 fails - but this is exactly where the onscreen keyboard starts. Could it be that there is some lock preventing inputs on specific components? Perhaps the treadmill app is also blocking programmatic inputs to the application ?

cagnulein commented 10 months ago

Perhaps the treadmill app is also blocking programmatic inputs to the application ?

never saw this before so I don't think so

but this is exactly where the onscreen keyboard starts

on screen keyboard? what do you mean? aren't we sliding the speed and incline slider with these coordinates?

Also I was checking again your log and

input swipe 1845 725 1845 725 200

and the y0 and y1 are the same! so that's why you don't see anything. I'm checking the code again

cagnulein commented 10 months ago

it seems that in that line, the companion already did that swipe, the first "725" was the last y1 coordinate that QZ sends. Try for example to send

input swipe 1845 785 1845 725 200

on the terminal app

samkenw commented 10 months ago

The onscreen keyboard in the terminal application I mean. That is how I am testing the swipes. As soon as the coordinates are on the keyboard, the command fails.

Same y positions is not an issue. When doing this in the terminal application I can see that there is an interaction.

samkenw commented 10 months ago

input swipe 1845 785 1845 725 200 fails because the coordinates hit the keyboard input swipe 1845 585 1845 525 200 works

cagnulein commented 10 months ago

ok so you can test from the terminal app to ifit for example doing

sleep 10 && input swipe 1845 725 1845 525 200

in the sleep time, go to the ifit app

do you know what I mean?

samkenw commented 10 months ago

Tested this. Even with values that work in the terminal app, when switching I am getting "Killed" return. Looks like cross-process input is somehow being blocked?

cagnulein commented 10 months ago

mmm yes I guess so. So we have 2 possibilites now 1) trying to reset the console, don't update ifit and see if you have the same behaviour 2a) if 1. is working, keep the old ifit 2b) if 2. is not working, we need to use the adb method somehow

Let me know

samkenw commented 10 months ago

okay, I can test that later some time. However, could it also be possible that there is a permission missing in the manifest? something like: uses-permission android:name="android.permission.INJECT_EVENTS" ? I suppose this would be for the original method.

Ah but I am seeing that for this to work the app needs to be signed by the system.

cagnulein commented 10 months ago

Ah but I am seeing that for this to work the app needs to be signed by the system.

yes but I also found this on the same thread https://stackoverflow.com/a/25014038

Can you access to that XML file?

cagnulein commented 10 months ago

also check this https://www.pocketmagic.net/injecting-events-programatically-on-android/ there is an apk to test it at the bottom

samkenw commented 10 months ago

Access to the XML requires privileges that I don't have.. (I believe the APK also needs a rooted device) I can try getting access later.

amasolov commented 10 months ago

@cagnulein experience the same problem on my NT x22i, the latest build of the companion and the last version of QZ (tried the google play version and the latest debug one from the repository). Would be interested to help if needed and see this resolved

amasolov commented 10 months ago

Actually, I just realized that I need to enable onscreen controls (sliders) to be able to control everything and it has started to work. Can we get a new build of QZ in Google Play to avoid the trial period of the debug version?

cagnulein commented 10 months ago

Actually, I just realized that I need to enable onscreen controls (sliders) to be able to control everything and it has started to work. Can we get a new build of QZ in Google Play to avoid the trial period of the debug version?

yes just join the beta from the play store @amasolov

@samkenw did you enable the onscreen controls that @amasolov mentioned? I guess so