cagnulein / QZCompanionNordictrackTreadmill

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

NordicTrack T7.5s no data in app #54

Closed slowjud closed 1 year ago

slowjud commented 1 year ago

Hi I'm trying to get this working on a T7.5s

The install went smoothly but no data is coming through.

I've attached the logs from the adb-debug.bat

Thanks

logcat.log logcat.txt 2023-07-21_logs.txt

cagnulein commented 1 year ago

Hi, in the wolflogs that you attached there is no metrics at all. are you sure you collected it while you were having a workout (not stopped, with the workout in progress) Let me know

Il giorno ven 21 lug 2023 alle 07:44 Jude Sutton @.***> ha scritto:

Hi I'm trying to get this working on a T7.5s

The install went smoothly but no data is coming through.

I've attached the logs from the adb-debug.bat

Thanks

logcat.log https://github.com/cagnulein/QZCompanionNordictrackTreadmill/files/12116671/logcat.log logcat.txt https://github.com/cagnulein/QZCompanionNordictrackTreadmill/files/12116673/logcat.txt 2023-07-21_logs.txt https://github.com/cagnulein/QZCompanionNordictrackTreadmill/files/12116678/2023-07-21_logs.txt

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/QZCompanionNordictrackTreadmill/issues/54, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWCJRHNCOO4XERNAXVLXRIJK5ANCNFSM6AAAAAA2SLQMFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

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

slowjud commented 1 year ago

Hi Roberto,

thanks for such a quick reply.

Yes this was during a workout. From what I see it just logs the startup then stops logging.

cagnulein commented 1 year ago

it's probably due to an ifit update or something. in this case the only way to get it working it's trying the direct access to the serial port of the treadmill without using the ifit app. are you able to share the ifit apk so i can try to deassemble it in the next days?

Il giorno ven 21 lug 2023 alle 07:58 Jude Sutton @.***> ha scritto:

Hi Roberto,

thanks for such a quick reply.

Yes this was during a workout. From what I see it just logs the startup then stops logging.

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

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

slowjud commented 1 year ago

The APK is too big for github, find it here: https://www.dropbox.com/s/k34f0jkd3mdfvw2/base.apk?dl=0

cagnulein commented 1 year ago

ok i'm in vacation right now, i will check it asap

Il giorno ven 21 lug 2023 alle 08:38 Jude Sutton @.***> ha scritto:

The APK is too big for github, find it here: https://www.dropbox.com/s/k34f0jkd3mdfvw2/base.apk?dl=0

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

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

cagnulein commented 1 year ago

The APK is too big for github, find it here: https://www.dropbox.com/s/k34f0jkd3mdfvw2/base.apk?dl=0

is this the only apk available in the treadmill? I already checked it and it doesn't contains a communication with the firmware of the treadmill. It seems more the graphic apk. Probably the low level apk is somewhere around

Let me know

slowjud commented 1 year ago

here are some more ifit apks I've also added the complete package for the ifit.standalone (my previous link was just the apk)

https://www.dropbox.com/s/wp9vigguh37hrak/com.ifit.standalone.zip?dl=0 https://www.dropbox.com/s/z2ylfkaunwvtgw2/com.ifit.launcher-1.0.17.22.zip?dl=0 https://www.dropbox.com/s/rutaiw25hxp36c8/com.ifit.eru-2.zip?dl=0 https://www.dropbox.com/s/wyawcz0ydcgo5c8/com.ifit.arda-1.zip?dl=0

cagnulein commented 1 year ago

ok thanks, i will check these in the next days

Il giorno ven 21 lug 2023 alle 13:27 Jude Sutton @.***> ha scritto:

here are some more ifit apks I've also added the complete package for the ifit.standalone (my previous link was just the apk)

https://www.dropbox.com/s/wp9vigguh37hrak/com.ifit.standalone.zip?dl=0

https://www.dropbox.com/s/z2ylfkaunwvtgw2/com.ifit.launcher-1.0.17.22.zip?dl=0 https://www.dropbox.com/s/rutaiw25hxp36c8/com.ifit.eru-2.zip?dl=0 https://www.dropbox.com/s/wyawcz0ydcgo5c8/com.ifit.arda-1.zip?dl=0

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

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

cagnulein commented 1 year ago

https://www.dropbox.com/s/wyawcz0ydcgo5c8/com.ifit.arda-1.zip?dl=0

this is the right one! @victorypoint I did a great discovery today! They don't use a serial port, but a classic USB HID communication like I did for https://github.com/cagnulein/qdomyos-zwift/pull/1510/files#diff-fa9a2ae4e5cf532f4b05f89057af23372b886b46351fd4470140ba02f883f10b

Of course I don't have the protocol but we can experiment with this. This will allow to rip out all the shitness from ifit and control and read the treadmill directly.

I will analyze this more in the next days

victorypoint commented 1 year ago

this is the right one! @victorypoint I did a great discovery today! They don't use a serial port, but a classic USB HID communication like I did for https://github.com/cagnulein/qdomyos-zwift/pull/1510/files#diff-fa9a2ae4e5cf532f4b05f89057af23372b886b46351fd4470140ba02f883f10b

@cagnulein, I think we went down this path before if I recall? Here is some debug info I posted in a previous ticket somewhere if it helps:

Found in logcat:
12-31 20:00:29.256   535   557 I UsbDeviceManager: Setting USB config to adb
12-31 20:00:29.659   535   557 W Looper  : Slow dispatch took 406ms android.fg h=com.android.server.usb.UsbDeviceManager$UsbHandlerLegacy c=null m=4
12-31 20:00:29.700  1103  1109 I adbd    : initializing functionfs
12-31 20:00:29.700  1103  1109 I adbd    : opening control endpoint /dev/usb-ffs/adb/ep0
12-31 20:00:29.702  1103  1109 I adbd    : functionfs successfully initialized
12-31 20:00:29.704  1103  1109 I adbd    : registering usb transport

adb shell ls /dev/bus/usb/002/
    001
    002
    Permission denied - c++ - libusb cannot open USB device, permission isse. NetBeans/Ubuntu - Stack Overflow

adb shell lsusb
    Bus 002 Device 002: ID 213c:0002
    Bus 001 Device 001: ID 1d6b:0002
    Bus 002 Device 001: ID 1d6b:0001

adb shell ls /
    init.mt8163.usb.rc - interesting
    init.usb.configfs.rc
    init.usb.rc

- adb shell getprop | grep "model\|version.sdk\|manufacturer\|hardware\|platform\|revision\|serialno\|product.name\|brand"
    [ro.board.platform]: [mt8163]
    [ro.boot.hardware]: [mt8163]
    [ro.boot.serialno]: [NN35Z109609]
    [ro.build.version.sdk]: [28]
    [ro.frp.pst]: [/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/frp]
    [ro.hardware]: [mt8163]
    [ro.hardware.nfc_nci]: [pn54x]
    [ro.mediatek.platform]: [MT8163]
    [ro.product.brand]: [iFit Embedded]
    [ro.product.manufacturer]: [Malata]
    [ro.product.model]: [MalataMediatekArgon2]
    [ro.product.name]: [argon2]
    [ro.product.vendor.brand]: [alps]
    [ro.product.vendor.manufacturer]: [alps]
    [ro.product.vendor.model]: [k2103]
    [ro.revision]: [0]
    [ro.serialno]: [NN35Z109609]
    [ro.vendor.mediatek.platform]: [MT8163]

- adb shell getprop | grep adb
    [init.svc.adbd]: [running]
    [persist.service.adb.tcp.port]: [5555]
    [persist.sys.usb.config]: [adb]
    [ro.adb.secure]: [1]
    [ro.boottime.adbd]: [26601662385]
    [sys.usb.config]: [adb]
    [sys.usb.state]: [adb]

- adb shell getprop | grep usb (treadmill idle on screen saver) - no change when running
    [init.svc.usbd]: [stopped]
    [init.svc.vendor.usb-hal-1-0]: [running]
    [persist.sys.usb.config]: [adb]
    [ro.audio.usb.period_us]: [16000]
    [ro.boottime.usbd]: [7838175230]
    [ro.boottime.vendor.usb-hal-1-0]: [3882140768]
    [ro.sys.usb.bicr]: [no]
    [ro.sys.usb.charging.only]: [yes]
    [ro.sys.usb.mtp.whql.enable]: [0]
    [ro.sys.usb.storage.type]: [mtp]
    [sys.allow_usb_debug]: [1]
    [sys.usb.config]: [adb]
    [sys.usb.configfs]: [1]
    [sys.usb.controller]: [musb-hdrc] - drivers/usb/gadget/Kconfig - kernel/mediatek - Git at Google (googlesource.com), device_blu_V0310WW/init.mt6771.usb.rc at Vivo_XI-user-9-PPR1.180610.011-1569469089-release-keys · AndroidBlobs/device_blu_V0310WW , (github.com), Chapter 2. Linux MUSB Basics (kernel.org)
    [sys.usb.ffs.ready]: [1]
    [sys.usb.state]: [adb]
    [sys.usb.vid]: [0E8D]
    [vendor.usb.acm_cnt]: [0]
    [vendor.usb.acm_enable]: [0]
    [vendor.usb.acm_port0]: []
    [vendor.usb.acm_port1]: []
    [vendor.usb.clear]: [boot]
    [vendor.usb.pid]: [0x201C]
    [vendor.usb.temp]: []
    [vendor.usb.vid]: [0x0E8D]

And here is the USB HID info from my C2950 TM:

        DEVICE INFO
        Device Path: /dev/bus/usb/002/002
        Device Class: Use class information in the Interface Descriptors (0x0)
        Vendor ID: 213c
        Vendor Name (reported): ICON Fitness
        Vendor Name (from DB): not found
        Product ID: 0002
        Product Name (reported): ICON Generic HID
        Product Name (from DB): not found

        ADDITIONAL INFO
        Interface #0 
        Class: Human Interaction Device (0x3)
        Endpoint: #0 
            Address :0x81 (10000001)
            Number :1
            Direction Inbound (0x80) 
            Type : Interrupt (0x3)
            Poll Interval: 1
            Max Packet Size: 64 
            Attributes : 00000011
        Endpoint: #1
            Address : 0x02 (00000010)
            Number :2
            Direction :Outbound (0x0) 
            Type :Interrupt (0x3)
            Poll Interval: 1
            Max Packet Size: 64 
        Attributes : 00000011

Interesting post about Android USB HID - https://stackoverflow.com/questions/52542934/android-usb-understanding-controltransfer-method

USB HID usage table - https://www.freebsddiary.org/APC/usb_hid_usages.php

cagnulein commented 1 year ago

Thanks @victorypoint they are the information that I need to go further. Actually I don't remember if we discussed about this in the past, but know I have a lot more knowledge about this because I did the same with with the concept2 rower. (So the hid library are already implemented on qz for example)

I will try to study the protocol and I will let you know

cagnulein commented 1 year ago

i'm adding some notes for the future myself: ifit uses protobuf (all protobuffers inside the resources directory) to build the messages. The only thing that I'm missing is what ifit uses to start the poll, maybe it sends just an empty protobuf

cagnulein commented 1 year ago

ok guys I'm preparing a QZ apk to run directly on the treadmill that will read the data from the USB. I will put here the link of the apk and the instructions to collect some data from the usb when I'm ready (hopefully today)

cagnulein commented 1 year ago

@victorypoint @slowjud ok apk ready for a first test https://github.com/cagnulein/qdomyos-zwift/suites/14543484924/artifacts/823071619

Steps:

Let me know!

victorypoint commented 1 year ago

@cagnulein, just to be clear, you want all ifit apps closed including main ifit one? Without it we cannot run a manual workout to collect metrics.

cagnulein commented 1 year ago

@cagnulein, just to be clear, you want all ifit apps closed including main ifit one? Without it we cannot run a manual workout to collect metrics.

yes exactly @victorypoint ALL the ifit app closed. That's because the apk that I provided will be replace the ifit ones! Unlocking it completely (as soon as I will complete it :) )

victorypoint commented 1 year ago

@cagnulein, all ifit apps closed/disabled, QZCompanion closed/disabled, USB app launches and immediately stops. I've captured a logcat with the open/close behavior. Screenshot included showing enabled permissions.

logcat.txt PXL_20230725_143806617 PXL_20230725_143741263

cagnulein commented 1 year ago

@victorypoint fixed thanks! I did a stupid copy and paste error. It's building, I will provide the new apk.

cagnulein commented 1 year ago

the good news is that QZ was already connected in the log! Wow!

cagnulein commented 1 year ago

@victorypoint @slowjud new build https://github.com/cagnulein/qdomyos-zwift/suites/14553652950/artifacts/823856996

victorypoint commented 1 year ago

@cagnulein, okay no QZ app crash this time. Did you want me to do anything in QZ? Attached is the logcat for QZ launch.

logcat.txt

cagnulein commented 1 year ago

@victorypoint thanks, the log in this way is perfect. Only a question: did you get a popup for the USB permission in qz? Because I saw in the log that it says that the user didn't give the permission to it.

cagnulein commented 1 year ago

I guess I can answer myself, we already got a hit!

07-25 19:47:00.638 11523 11718 D HidBridge: Message received of lengths 64 and content: 4 46 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 44 1 0 0 0 0 -76 0 0 0 0 0 0 0 0 0 24 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

the treadmill is already sending something! Let's decode this with the protobuf that are available in the apk. I guess I can use chatgpt for this :)

victorypoint commented 1 year ago

@cagnulein, ok great news. Yes a permission pop-up appeared which I granted.

cagnulein commented 1 year ago

@victorypoint new apk ready https://github.com/cagnulein/qdomyos-zwift/suites/14580674006/artifacts/825950838 same test as before if you can, thanks!

victorypoint commented 1 year ago

@cagnulein, thanks! New apk installed and launched. Attached is the logcat.

logcat.txt

cagnulein commented 1 year ago

@victorypoint in the ifit log, did you see something about the ifit.eru app? i mean in the code i saw that it's logging (also the low level communication) but I don't know where. I don't think it's in the classic logcat file. It could be useful to get the actual log from ifit usb communication to understand what's doing on the startup phase.

cagnulein commented 1 year ago

note for me: i just found this one http://apk-deguard.com/ It works really well!

victorypoint commented 1 year ago

@victorypoint in the ifit log, did you see something about the ifit.eru app? i mean in the code i saw that it's logging (also the low level communication) but I don't know where.

The ifit apps are disabled so the ifit logs would not be updated but I could supply them if you need them? I would simply issue these commands. Let me know.

adb pull /sdcard/.wolflogs/
adb pull /sdcard/eru/

I don't think it's in the classic logcat file. It could be useful to get the actual log from ifit usb communication to understand what's doing on the startup phase.

@cagnulein, you're right, the logcat I posted previously was captured live streamed when I launched QZ on the tablet. This time I disabled all ifit apps, set QZ to launch on treadmill start, and rebooted treadmill. The attached logcat was captured with the traditional "adb logcat -d > logcat.txt" after the treadmill started and QZ launched.

logcat.txt

cagnulein commented 1 year ago

The ifit apps are disabled so the ifit logs would not be updated but I could supply them if you need them? I would simply issue these commands. Let me know.

adb pull /sdcard/.wolflogs/
adb pull /sdcard/eru/

yes i'm interested in the eru subfolder actually Thanks

victorypoint commented 1 year ago

@cagnulein, okay I reset the treadmill back to normal, started a manual workout and captured all the ifit logs.

ifit-logs.zip

cagnulein commented 1 year ago

@victorypoint can you do again the same test with this apk? https://github.com/cagnulein/qdomyos-zwift/suites/14652532576/artifacts/831407139

As I said on messenger I found a new logic in the log from the user that could explain why I didn't get a real metrics in the past logs.

Thanks!

victorypoint commented 1 year ago

@cagnulein, here's the logs for the new qz apk.

new-logs.zip

cagnulein commented 1 year ago

@slowjud another user with your same issue fixed it resetting the console completely and without update the ifit software (it seems the new ifit has this issue).

Let me know

@victorypoint i'm checking what i'm doing wrong in the init phase, thanks

victorypoint commented 1 year ago

Hi I'm trying to get this working on a T7.5s

The install went smoothly but no data is coming through.

I've attached the logs from the adb-debug.bat

Thanks

logcat.log logcat.txt 2023-07-21_logs.txt

Sorry guys, I'm just looking at these logs right now. I should have looked at them closer before. @cagnulein, in logcat.txt I'm seeing a slightly different wording for a metric change, for example:

[Trace:FitPro] Changed Actual KPH to: 1.56

cagnulein commented 1 year ago

Omg @victorypoint I'm blind! I will implement this tomorrow, thank you very much for the double check! @slowjud great news! Are you still interested?

victorypoint commented 1 year ago

@cagnulein, this is excellent news. We discussed in the past about using logcat instead of wolflog for reading real-time metrics but I can't remember what we decided.

cagnulein commented 1 year ago

Ah they are only on the logcat, now I see this! Logcat requires shell access and it could be slower, but I can add it as a setting in order to workaround this particular scenario

slowjud commented 1 year ago

Wow, You both are awesome. I'm still interested in getting this running.

cagnulein commented 1 year ago

@slowjud great! I did the modification. You can download the newest version from here https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.0/QZCompanionNordictrackTreadmill.apk

After installing it, select the new 7.5s device setting and restart the treadmill. Let me know if it makes any difference and in case send me the logs (I can't test this on my own, so I just wrote the code).

It could be slow, but in case I know how to fix it (clearing the logcat cache after each reading)

slowjud commented 1 year ago

@cagnulein no dice, Here are the logs logcat.log logcat.txt

cagnulein commented 1 year ago

@slowjud I guess I understood the issue. Update with this new one https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.1/QZCompanionNordictrackTreadmill.apk

Let me know

slowjud commented 1 year ago

here are the latest logs. logcat.txt logcat.log

cagnulein commented 1 year ago

@slowjud did you do debug access to the companion? image

i saw in the log that it can't connect to adb locally. if you press on the dump log button, are you seeing the log on the companion, right?

slowjud commented 1 year ago

Thanks, I've tried this, here is the latest log. One comment, I can't connect via adb when the companion app has debug (maybe that's expected) logcat.log

slowjud commented 1 year ago

Here's the logs from the iOS app debug-Wed_Aug_2_15_34_11_2023.log

cagnulein commented 1 year ago

great! it worked! i have only to fix another small issue. I'm doing it right now!

cagnulein commented 1 year ago

new apk https://github.com/cagnulein/QZCompanionNordictrackTreadmill/releases/download/3.3.2/QZCompanionNordictrackTreadmill.apk @slowjud Let me know!

slowjud commented 1 year ago

More logs for you. it got something after I pressed dump log in the companion logcat.log

cagnulein commented 1 year ago

@slowjud actually now it's working from what I'm seeing in the log. What do you get on the ios app? nothing? send me a debug log from it and I will check it now. Thanks