Compare commits

...

13 Commits

Author SHA1 Message Date
Roberto Viola
f9a7e70be5 Update project.pbxproj 2026-02-02 14:58:41 +01:00
Roberto Viola
0f81ad3545 Merge branch 'master' into claude/fix-ios-qml-scrolling-L6afM 2026-02-02 13:45:54 +00:00
Roberto Viola
33b686bf3e Add weight unit preference for miles users (#4261)
* Add weight unit toggle for UK users (kg with miles)

Adds a new setting "Use kg for weight" that allows users to use
kilograms for weight even when miles is selected for distance.
This is useful for UK users who typically use miles for distance
but kg for body weight.

The toggle appears only when "Use Miles unit in UI" is enabled.
Updated Player Weight, Bike Weight in settings.qml and Wizard.qml.

https://claude.ai/code/session_01B4HhW9pAva8fC7EtgQ8jRo

* Update Wizard.qml

* Update Wizard.qml

* Update settings.qml

* Add weight unit toggle for UK users (kg with miles)

Adds a new setting "Use kg for weight" that allows users to use
kilograms for weight even when miles is selected for distance.
This is useful for UK users who typically use miles for distance
but kg for body weight.

The toggle appears only when "Use Miles unit in UI" is enabled.
Updated Player Weight, Bike Weight in settings.qml and Wizard.qml.

https://claude.ai/code/session_01B4HhW9pAva8fC7EtgQ8jRo

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-02 14:21:10 +01:00
Roberto Viola
74e1aba909 horizon gr7 power data bug (Issue #4250) 2026-02-02 12:03:33 +01:00
Claude
5709e18106 Improve touch handling with larger resize handle and better event checks
Changes to fix touch interaction issues:

1. Resize Handle Improvements (50x50px instead of 20x20px):
   - Increased size from 20x20 to 50x50 pixels for easier touch targeting
   - Added visible resize icon (⤡) with better contrast
   - More opaque background for better visibility

2. Event Listener Safety:
   - Added isInsideContainer() check to verify touch starts in container
   - Added early return in handleMove() if not dragging/resizing
   - Always remove listeners in endDragOrResize() to prevent leaks
   - Added touchcancel event handling for system interruptions
   - Fixed logic to check wasResizing before accessing it

3. Better State Management:
   - Always reset isDragging/isResizing before removing listeners
   - Only save state if actually was dragging or resizing
   - Prevents stale listener references

This should fix:
- Difficulty grabbing resize handle on touch devices
- Box moving when interacting with Cesium map
- Event listeners remaining active when they shouldn't
2026-02-01 08:13:50 +00:00
Roberto Viola
bf75b2bda0 Add Thinkrider VS200 controller support for gear shifting (#4242)
* Add Thinkrider VS200 controller support for gear shifting

Implements support for the Thinkrider VS200 remote controller,
enabling gear up/down functionality similar to Zwift Click.
Uses service UUID 0000fea0 and detects button patterns for
shift up (f3050301fc) and shift down (f3050300fb).

https://claude.ai/code/session_01DK5qQY9wKyHTKfYhAkGECS

* Update allSettingsCount to 857 for thinkrider_controller setting

https://claude.ai/code/session_01DK5qQY9wKyHTKfYhAkGECS

* Update project.pbxproj

* Update project.pbxproj

* Update project.pbxproj

* Add device discovery wait for Thinkrider and create separate settings section

- Add thinkriderDeviceAvaiable() function for discovery wait logic
- Add thinkriderDeviceFound checks in bluetooth constructor and deviceDiscovered
- Create separate "Thinkrider Options" accordion section in settings.qml
- Remove Thinkrider from Zwift Devices Options section

https://claude.ai/code/session_01DK5qQY9wKyHTKfYhAkGECS

* Update project.pbxproj

* Update bluetooth.cpp

* Update project.pbxproj

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-31 21:23:42 +01:00
Roberto Viola
80faa062e1 Add Garmin server selection and debug logging (#4235)
* Add Garmin server selection and debug logging

Introduces a ComboBox in settings to select between global and China Garmin servers, prompting for app restart when changed. Adds debug logging in garminconnect.cpp to trace domain and API URLs, and logs the loaded domain from settings.

* Add verbose debug logging for GarminConnect responses

Introduces a DEBUG_GARMIN_VERBOSE flag to enable detailed logging of HTTP responses and ticket extraction attempts in the GarminConnect authentication flow. This aids in troubleshooting login and MFA issues by providing more insight into response contents and extraction logic.

* Detect MFA via page title and handle CSRF

Instead of scanning the entire response body for "MFA", detect MFA by parsing the HTML <title> (matching the Python garth approach) to avoid false positives from bodies that contain "MFA" text. Extract the page title early, check for "MFA" case-insensitively, and if detected update m_lastError, refresh cookies, extract a new CSRF token using two regex patterns, emit mfaRequired (unless suppressed), and abort the login flow. Also adjust the success check to rely on the title == "Success" and remove the legacy body-based MFA detection block. Added debugging logs for the title, CSRF token, and MFA signal paths.

* Update garminconnect.h

* popup not needed
2026-01-31 20:19:05 +01:00
Roberto Viola
51808cc8a4 Set RepetitionNum to lap_index
In src/qfit.cpp (qfit::save) for JUMPROPE laps, use lap_index when calling lapMesg.SetRepetitionNum instead of session.at(i - 1).inclination. This makes the repetition number reflect the lap index and avoids relying on session data that could be incorrect or out-of-range.
2026-01-31 08:00:07 +01:00
Claude
8beafd521b Fix touch event handling to prevent Cesium interference
The previous implementation had critical issues:
1. Global document touchmove listeners were always active, capturing
   all touch events including those on the Cesium map
2. Resize handle detection using e.target was unreliable on touch devices

Changes:
- Remove permanently-active global listeners on document
- Add/remove global listeners dynamically only when drag/resize starts/ends
- Implement isInResizeHandle() function using coordinate-based detection
  instead of e.target checking (checks if touch is in bottom-right 20x20px)
- Consolidate mousedown/touchstart handlers on container to use the same
  coordinate-based logic for determining drag vs resize

This ensures:
- Cesium map remains fully interactive when not touching metrics box
- Resize handle works reliably on touch devices
- No event leakage between UI elements and the map
2026-01-29 11:14:12 +00:00
Claude
5a984f7bdf Add z-index and chart following functionality for metrics box
Changes:
- Add z-index: 1000 to metricsContainer and 999 to chartContainer to ensure
  they appear above the Cesium map and properly capture touch events
- Add touch-action: none to inner .metrics div and chartContainer for better
  touch event handling on iOS/Android
- Implement updateChartPosition() to make the elevation chart follow the
  metrics box when dragging or resizing
- Chart maintains 10px left offset and bottom alignment with metrics box
- Chart position updates during drag, resize, and on page load

This ensures the metrics box and chart can be interacted with on mobile
devices without interfering with the Cesium map underneath.
2026-01-29 10:06:33 +00:00
Roberto Viola
39b77effd1 Merge branch 'master' into claude/fix-ios-qml-scrolling-L6afM 2026-01-27 15:13:10 +01:00
Claude
eb8f33fcda Remove overly aggressive CSS that blocked map interaction
The previous fix prevented page scrolling but also disabled
Cesium map interaction (pan, zoom, rotate). The touch-action: none
on metricsContainer combined with passive: false listeners and
stopPropagation() should be sufficient to prevent scrolling only
when interacting with the metrics box.
2026-01-20 13:12:08 +00:00
Claude
1154cadbe8 Fix iOS QML scrolling issue when interacting with metrics box
The metrics container drag/resize functionality was causing page scrolling
on iOS within the QML WebView instead of allowing box manipulation.

Changes:
- Add { passive: false } to touchstart event listeners to ensure preventDefault() works on iOS
- Add stopPropagation() to startDrag() and handleMove() to prevent event bubbling
- Add CSS rules to body/html to disable scrolling and overscroll behavior
- Prevent default touch actions on the entire viewport

This ensures that touch events on the metrics box are properly captured
and don't trigger page scrolling on iOS devices.
2026-01-20 13:05:58 +00:00
18 changed files with 684 additions and 93 deletions

View File

@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(git log:*)"
]
}
}

View File

@@ -557,6 +557,8 @@
87DAE16926E9FF5000B0527E /* moc_shuaa5treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16626E9FF5000B0527E /* moc_shuaa5treadmill.cpp */; };
87DAE16A26E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16726E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp */; };
87DAE16B26E9FF5000B0527E /* moc_solef80treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16826E9FF5000B0527E /* moc_solef80treadmill.cpp */; };
87DBD5DB2F2CEE1900342F2B /* thinkridercontroller.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DBD5DA2F2CEE1900342F2B /* thinkridercontroller.cpp */; };
87DBD5ED2F2CF22100342F2B /* moc_thinkridercontroller.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DBD5EC2F2CF22100342F2B /* moc_thinkridercontroller.cpp */; };
87DC27EA2D9BDB53007A1B9D /* echelonstairclimber.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DC27E72D9BDB53007A1B9D /* echelonstairclimber.cpp */; };
87DC27EB2D9BDB53007A1B9D /* stairclimber.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DC27E92D9BDB53007A1B9D /* stairclimber.cpp */; };
87DC27EE2D9BDB8F007A1B9D /* moc_stairclimber.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DC27ED2D9BDB8F007A1B9D /* moc_stairclimber.cpp */; };
@@ -1660,6 +1662,9 @@
87DAE16626E9FF5000B0527E /* moc_shuaa5treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_shuaa5treadmill.cpp; sourceTree = "<group>"; };
87DAE16726E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_kingsmithr2treadmill.cpp; sourceTree = "<group>"; };
87DAE16826E9FF5000B0527E /* moc_solef80treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_solef80treadmill.cpp; sourceTree = "<group>"; };
87DBD5D92F2CEE1900342F2B /* thinkridercontroller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = thinkridercontroller.h; path = ../src/devices/thinkridercontroller/thinkridercontroller.h; sourceTree = SOURCE_ROOT; };
87DBD5DA2F2CEE1900342F2B /* thinkridercontroller.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = thinkridercontroller.cpp; path = ../src/devices/thinkridercontroller/thinkridercontroller.cpp; sourceTree = SOURCE_ROOT; };
87DBD5EC2F2CF22100342F2B /* moc_thinkridercontroller.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = moc_thinkridercontroller.cpp; sourceTree = "<group>"; };
87DC27E62D9BDB53007A1B9D /* echelonstairclimber.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = echelonstairclimber.h; path = ../src/devices/echelonstairclimber/echelonstairclimber.h; sourceTree = SOURCE_ROOT; };
87DC27E72D9BDB53007A1B9D /* echelonstairclimber.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = echelonstairclimber.cpp; path = ../src/devices/echelonstairclimber/echelonstairclimber.cpp; sourceTree = SOURCE_ROOT; };
87DC27E82D9BDB53007A1B9D /* stairclimber.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = stairclimber.h; path = ../src/devices/stairclimber.h; sourceTree = SOURCE_ROOT; };
@@ -2335,6 +2340,9 @@
2EB56BE3C2D93CDAB0C52E67 /* Sources */ = {
isa = PBXGroup;
children = (
87DBD5EC2F2CF22100342F2B /* moc_thinkridercontroller.cpp */,
87DBD5D92F2CEE1900342F2B /* thinkridercontroller.h */,
87DBD5DA2F2CEE1900342F2B /* thinkridercontroller.cpp */,
87A892572F0C173600811D95 /* sportsplusrower.cpp */,
87A892552F0C12EB00811D95 /* deerruntreadmill.cpp */,
87CBCF0F2EFAA2F8004F5ECE /* garminconnect.h */,
@@ -3892,6 +3900,7 @@
87FE5BAF2692F3130056EFC8 /* tacxneo2.cpp in Compile Sources */,
8718CBAC263063CE004BF4EE /* moc_tcpclientinfosender.cpp in Compile Sources */,
873824B527E64707004F1B46 /* moc_provider_p.cpp in Compile Sources */,
87DBD5ED2F2CF22100342F2B /* moc_thinkridercontroller.cpp in Compile Sources */,
87097D2F275EA9A30020EE6F /* sportsplusbike.cpp in Compile Sources */,
333C629F93DB3941862924F7 /* fit_field_base.cpp in Compile Sources */,
87473A9827ECAA0500C203F5 /* moc_proformrower.cpp in Compile Sources */,
@@ -4198,6 +4207,7 @@
874D272029AFA11F0007C079 /* apexbike.cpp in Compile Sources */,
8798C8872733E103003148B3 /* strydrunpowersensor.cpp in Compile Sources */,
87C5F0B626285E5F0067A1B5 /* quotedprintable.cpp in Compile Sources */,
87DBD5DB2F2CEE1900342F2B /* thinkridercontroller.cpp in Compile Sources */,
87310B23266FBB78008BA0D6 /* moc_smartrowrower.cpp in Compile Sources */,
EE29228550794460E7654533 /* moc_trxappgateusbtreadmill.cpp in Compile Sources */,
3DB7B5F0CE1E2390CEFFC1E8 /* moc_virtualbike.cpp in Compile Sources */,
@@ -4573,7 +4583,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
@@ -4774,7 +4784,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEBUG_INFORMATION_FORMAT = dwarf;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 6335M7T29D;
@@ -5011,7 +5021,7 @@
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5107,7 +5117,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
@@ -5199,7 +5209,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
ENABLE_PREVIEWS = YES;
@@ -5315,7 +5325,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
@@ -5425,7 +5435,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = QZWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -5516,7 +5526,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = QZWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1274;
CURRENT_PROJECT_VERSION = 1278;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_NS_ASSERTIONS = NO;

View File

@@ -31,9 +31,11 @@ Page {
property int age: 35
property string sex: "Male"
property bool miles_unit: false
property bool weight_kg_unit: false
property string heart_rate_belt_name: "Disabled"
property bool garmin_companion: false
property string filter_device: "Disabled"
property bool weight_kg_unit: false
}
background: Rectangle {
@@ -1181,7 +1183,7 @@ Page {
Text {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Weight (" + (settings.miles_unit ? "lbs" : "kg") + ")")
text: qsTr("Weight (" + ((settings.miles_unit && !settings.weight_kg_unit) ? "lbs" : "kg") + ")")
font.pixelSize: 20
color: "white"
}
@@ -1189,13 +1191,13 @@ Page {
SpinBox {
id: weightSpinBox
Layout.alignment: Qt.AlignHCenter
from: settings.miles_unit ? 660 : 300 // 66.0 lbs or 30.0 kg
to: settings.miles_unit ? 4400 : 2000 // 440.0 lbs or 200.0 kg
value: settings.miles_unit ? (settings.weight * 2.20462 * 10).toFixed(0) : (settings.weight * 10)
from: (settings.miles_unit && !settings.weight_kg_unit) ? 660 : 300 // 66.0 lbs or 30.0 kg
to: (settings.miles_unit && !settings.weight_kg_unit) ? 4400 : 2000 // 440.0 lbs or 200.0 kg
value: (settings.miles_unit && !settings.weight_kg_unit) ? (settings.weight * 2.20462 * 10).toFixed(0) : (settings.weight * 10)
stepSize: 1
editable: true
property real realValue: settings.miles_unit ? value / 22.0462 : value / 10
property real realValue: (settings.miles_unit && !settings.weight_kg_unit) ? value / 22.0462 : value / 10
textFromValue: function(value, locale) {
return Number(value / 10).toLocaleString(locale, 'f', 1)

View File

@@ -201,12 +201,15 @@ void bluetooth::finished() {
bool sramDeviceFound = !settings.value(QZSettings::sram_axs_controller, QZSettings::default_sram_axs_controller).toBool();
bool thinkriderDeviceFound = !settings.value(QZSettings::thinkrider_controller, QZSettings::default_thinkrider_controller).toBool();
if ((!heartRateBeltFound && !heartRateBeltAvaiable()) || (!ftmsAccessoryFound && !ftmsAccessoryAvaiable()) ||
(!cscFound && !cscSensorAvaiable()) || (!powerSensorFound && !powerSensorAvaiable()) ||
(!eliteRizerFound && !eliteRizerAvaiable()) || (!eliteSterzoSmartFound && !eliteSterzoSmartAvaiable()) ||
(!fitmetriaFanfitFound && !fitmetriaFanfitAvaiable()) ||
(!zwiftDeviceFound && !zwiftDeviceAvaiable()) ||
(!sramDeviceFound && !sramDeviceAvaiable())) {
(!sramDeviceFound && !sramDeviceAvaiable()) ||
(!thinkriderDeviceFound && !thinkriderDeviceAvaiable())) {
// force heartRateBelt off
forceHeartBeltOffForTimeout = true;
@@ -336,6 +339,16 @@ bool bluetooth::sramDeviceAvaiable() {
return false;
}
bool bluetooth::thinkriderDeviceAvaiable() {
Q_FOREACH (QBluetoothDeviceInfo b, devices) {
if (b.name().toUpper().startsWith("THINK VS") || b.name().toUpper().startsWith("THINKRIDER")) {
return true;
}
}
return false;
}
bool bluetooth::powerSensorAvaiable() {
@@ -437,6 +450,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
bool sramDeviceFound = !settings.value(QZSettings::sram_axs_controller, QZSettings::default_sram_axs_controller).toBool();
bool zwiftDeviceFound =
!settings.value(QZSettings::zwift_click, QZSettings::default_zwift_click).toBool() && !settings.value(QZSettings::zwift_play, QZSettings::default_zwift_play).toBool();
bool thinkriderDeviceFound = !settings.value(QZSettings::thinkrider_controller, QZSettings::default_thinkrider_controller).toBool();
bool fitmetriaFanfitFound =
!settings.value(QZSettings::fitmetria_fanfit_enable, QZSettings::default_fitmetria_fanfit_enable).toBool();
bool toorx_ftms = settings.value(QZSettings::toorx_ftms, QZSettings::default_toorx_ftms).toBool();
@@ -549,6 +563,10 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
sramDeviceFound = sramDeviceAvaiable();
}
if(!thinkriderDeviceFound) {
thinkriderDeviceFound = thinkriderDeviceAvaiable();
}
if (!ftmsAccessoryFound) {
ftmsAccessoryFound = ftmsAccessoryAvaiable();
@@ -681,7 +699,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
#endif
bool searchDevices = (heartRateBeltFound && ftmsAccessoryFound && cscFound && powerSensorFound && eliteRizerFound &&
eliteSterzoSmartFound && fitmetriaFanfitFound && zwiftDeviceFound) ||
eliteSterzoSmartFound && fitmetriaFanfitFound && zwiftDeviceFound && sramDeviceFound && thinkriderDeviceFound) ||
forceHeartBeltOffForTimeout;
if (searchDevices) {
@@ -1836,8 +1854,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
!b.name().compare(ftms_bike, Qt::CaseInsensitive) || (b.name().toUpper().startsWith("SMB1")) ||
(b.name().toUpper().startsWith("UBIKE FTMS")) || (b.name().toUpper().startsWith("INRIDE")) ||
(b.name().toUpper().startsWith("INCONDI")) || // inCondi S150i
(b.name().toUpper().startsWith("YPBM") && b.name().length() == 10) ||
(b.name().toUpper().startsWith("JFICCYCLE"))) &&
(b.name().toUpper().startsWith("YPBM") && b.name().length() == 10)) &&
ftms_rower.contains(QZSettings::default_ftms_rower) &&
!ftmsBike && !ftmsRower && !snodeBike && !fitPlusBike && !stagesBike && filter) {
this->setLastBluetoothDevice(b);
@@ -3115,6 +3132,24 @@ void bluetooth::connectedAndDiscovered() {
}
}
if(settings.value(QZSettings::thinkrider_controller, QZSettings::default_thinkrider_controller).toBool()) {
for (const QBluetoothDeviceInfo &b : qAsConst(devices)) {
if (((b.name().toUpper().startsWith("THINK VS")) || (b.name().toUpper().startsWith("THINKRIDER"))) && !thinkriderController && this->device() &&
this->device()->deviceType() == BIKE) {
thinkriderController = new thinkridercontroller(this->device());
connect(thinkriderController, &thinkridercontroller::debug, this, &bluetooth::debug);
connect(thinkriderController, &thinkridercontroller::plus, (bike*)this->device(), &bike::gearUp);
connect(thinkriderController, &thinkridercontroller::minus, (bike*)this->device(), &bike::gearDown);
thinkriderController->deviceDiscovered(b);
if(homeform::singleton())
homeform::singleton()->setToastRequested("Thinkrider Controller Connected!");
break;
}
}
}
if(settings.value(QZSettings::zwift_play, QZSettings::default_zwift_play).toBool()) {
for (const QBluetoothDeviceInfo &b : qAsConst(devices)) {
if (((b.name().toUpper().startsWith("SQUARE"))) && !eliteSquareController && this->device() &&

View File

@@ -154,6 +154,7 @@
#include "zwift_play/zwiftPlayDevice.h"
#include "zwift_play/zwiftclickremote.h"
#include "devices/thinkridercontroller/thinkridercontroller.h"
#ifdef Q_OS_IOS
#include "ios/lockscreen.h"
@@ -306,6 +307,7 @@ class bluetooth : public QObject, public SignalHandler {
QList<eliteariafan *> eliteAriaFan;
QList<zwiftclickremote* > zwiftPlayDevice;
zwiftclickremote* zwiftClickRemote = nullptr;
thinkridercontroller* thinkriderController = nullptr;
sramaxscontroller* sramAXSController = nullptr;
elitesquarecontroller* eliteSquareController = nullptr;
QString filterDevice = QLatin1String("");
@@ -343,6 +345,7 @@ class bluetooth : public QObject, public SignalHandler {
bool fitmetriaFanfitAvaiable();
bool zwiftDeviceAvaiable();
bool sramDeviceAvaiable();
bool thinkriderDeviceAvaiable();
bool fitmetria_fanfit_isconnected(QString name);
#ifdef Q_OS_WIN

View File

@@ -753,10 +753,6 @@ void ftmsbike::characteristicChanged(const QLowEnergyCharacteristic &characteris
} else if (MRK_S26C) {
m_watt = Cadence.value() * (Resistance.value() * 1.16);
emit debug(QStringLiteral("Current Watt (MRK-S26C formula): ") + QString::number(m_watt.value()));
} else if (JFICCYCLE) {
// JFICCYCLE sends power but always at 0, so calculate from cadence or heart rate
m_watt = wattFromHR(true);
emit debug(QStringLiteral("Current Watt (JFICCYCLE calculated): ") + QString::number(m_watt.value()));
} else if (LYDSTO && watt_ignore_builtin) {
m_watt = wattFromHR(true);
emit debug(QStringLiteral("Current Watt: ") + QString::number(m_watt.value()));
@@ -1829,9 +1825,6 @@ void ftmsbike::deviceDiscovered(const QBluetoothDeviceInfo &device) {
qDebug() << QStringLiteral("S18 found");
S18 = true;
max_resistance = 24;
} else if(device.name().toUpper().startsWith("JFICCYCLE")) {
qDebug() << QStringLiteral("JFICCYCLE found");
JFICCYCLE = true;
}

View File

@@ -172,7 +172,6 @@ class ftmsbike : public bike {
bool SPORT01 = false;
bool FS_YK = false;
bool S18 = false;
bool JFICCYCLE = false;
bool ZIPRO_RAVE = false;
uint8_t secondsToResetTimer = 5;

View File

@@ -0,0 +1,225 @@
#include "thinkridercontroller.h"
#include "homeform.h"
#include <QBluetoothLocalDevice>
#include <QDateTime>
#include <QEventLoop>
#include <QFile>
#include <QMetaEnum>
#include <QSettings>
#include <QThread>
using namespace std::chrono_literals;
// Thinkrider VS200 UUIDs
const QBluetoothUuid thinkridercontroller::SERVICE_UUID =
QBluetoothUuid(QStringLiteral("0000fea0-0000-1000-8000-00805f9b34fb"));
const QBluetoothUuid thinkridercontroller::CHARACTERISTIC_UUID =
QBluetoothUuid(QStringLiteral("0000fea1-0000-1000-8000-00805f9b34fb"));
// Button patterns (from swiftcontrol implementation)
const QByteArray thinkridercontroller::SHIFT_UP_PATTERN = QByteArray::fromHex("f3050301fc");
const QByteArray thinkridercontroller::SHIFT_DOWN_PATTERN = QByteArray::fromHex("f3050300fb");
thinkridercontroller::thinkridercontroller(bluetoothdevice *parentDevice) {
this->parentDevice = parentDevice;
}
void thinkridercontroller::serviceDiscovered(const QBluetoothUuid &gatt) {
emit debug(QStringLiteral("serviceDiscovered ") + gatt.toString());
}
void thinkridercontroller::disconnectBluetooth() {
qDebug() << QStringLiteral("thinkridercontroller::disconnect") << m_control;
if (m_control) {
m_control->disconnectFromDevice();
}
}
void thinkridercontroller::characteristicChanged(const QLowEnergyCharacteristic &characteristic,
const QByteArray &newValue) {
Q_UNUSED(characteristic);
qDebug() << QStringLiteral("thinkridercontroller << ") << newValue.toHex(' ');
// Check for shift up pattern
if (newValue == SHIFT_UP_PATTERN) {
qDebug() << QStringLiteral("Thinkrider: Shift UP detected");
emit plus();
}
// Check for shift down pattern
else if (newValue == SHIFT_DOWN_PATTERN) {
qDebug() << QStringLiteral("Thinkrider: Shift DOWN detected");
emit minus();
}
}
void thinkridercontroller::stateChanged(QLowEnergyService::ServiceState state) {
QMetaEnum metaEnum = QMetaEnum::fromType<QLowEnergyService::ServiceState>();
emit debug(QStringLiteral("BTLE stateChanged ") + QString::fromLocal8Bit(metaEnum.valueToKey(state)));
for (QLowEnergyService *s : qAsConst(gattCommunicationChannelService)) {
qDebug() << QStringLiteral("stateChanged") << s->serviceUuid() << s->state();
if (s->state() != QLowEnergyService::ServiceDiscovered && s->state() != QLowEnergyService::InvalidService) {
qDebug() << QStringLiteral("not all services discovered");
return;
}
}
if (state != QLowEnergyService::ServiceState::ServiceDiscovered) {
qDebug() << QStringLiteral("ignoring this state");
return;
}
qDebug() << QStringLiteral("all services discovered!");
for (QLowEnergyService *s : qAsConst(gattCommunicationChannelService)) {
if (s->state() == QLowEnergyService::ServiceDiscovered) {
// establish hook into notifications
connect(s, &QLowEnergyService::characteristicChanged, this, &thinkridercontroller::characteristicChanged);
connect(s, &QLowEnergyService::characteristicRead, this, &thinkridercontroller::characteristicChanged);
connect(
s, static_cast<void (QLowEnergyService::*)(QLowEnergyService::ServiceError)>(&QLowEnergyService::error),
this, &thinkridercontroller::errorService);
connect(s, &QLowEnergyService::descriptorWritten, this, &thinkridercontroller::descriptorWritten);
qDebug() << s->serviceUuid() << QStringLiteral("connected!");
auto characteristics_list = s->characteristics();
for (const QLowEnergyCharacteristic &c : qAsConst(characteristics_list)) {
qDebug() << QStringLiteral("char uuid") << c.uuid() << QStringLiteral("handle") << c.handle();
auto descriptors_list = c.descriptors();
for (const QLowEnergyDescriptor &d : qAsConst(descriptors_list)) {
qDebug() << QStringLiteral("descriptor uuid") << d.uuid() << QStringLiteral("handle") << d.handle();
}
if ((c.properties() & QLowEnergyCharacteristic::Notify) == QLowEnergyCharacteristic::Notify) {
QByteArray descriptor;
descriptor.append((char)0x01);
descriptor.append((char)0x00);
if (c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).isValid()) {
s->writeDescriptor(c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), descriptor);
} else {
qDebug() << QStringLiteral("ClientCharacteristicConfiguration") << c.uuid()
<< c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).uuid()
<< c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).handle()
<< QStringLiteral(" is not valid");
}
qDebug() << s->serviceUuid() << c.uuid() << QStringLiteral("notification subscribed!");
} else if ((c.properties() & QLowEnergyCharacteristic::Indicate) ==
QLowEnergyCharacteristic::Indicate) {
QByteArray descriptor;
descriptor.append((char)0x02);
descriptor.append((char)0x00);
if (c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).isValid()) {
s->writeDescriptor(c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), descriptor);
} else {
qDebug() << QStringLiteral("ClientCharacteristicConfiguration") << c.uuid()
<< c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).uuid()
<< c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration).handle()
<< QStringLiteral(" is not valid");
}
qDebug() << s->serviceUuid() << c.uuid() << QStringLiteral("indication subscribed!");
}
if (c.uuid() == CHARACTERISTIC_UUID) {
qDebug() << QStringLiteral("Thinkrider characteristic found");
gattNotifyCharacteristic = c;
}
}
}
}
initDone = true;
}
void thinkridercontroller::descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue) {
emit debug(QStringLiteral("descriptorWritten ") + descriptor.name() + " " + newValue.toHex(' '));
}
void thinkridercontroller::serviceScanDone(void) {
emit debug(QStringLiteral("serviceScanDone"));
auto services_list = m_control->services();
for (const QBluetoothUuid &s : qAsConst(services_list)) {
gattCommunicationChannelService.append(m_control->createServiceObject(s));
if (gattCommunicationChannelService.constLast()) {
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
&thinkridercontroller::stateChanged);
gattCommunicationChannelService.constLast()->discoverDetails();
} else {
m_control->disconnectFromDevice();
}
}
}
void thinkridercontroller::errorService(QLowEnergyService::ServiceError err) {
QMetaEnum metaEnum = QMetaEnum::fromType<QLowEnergyService::ServiceError>();
emit debug(QStringLiteral("thinkridercontroller::errorService") + QString::fromLocal8Bit(metaEnum.valueToKey(err)) +
m_control->errorString());
}
void thinkridercontroller::error(QLowEnergyController::Error err) {
QMetaEnum metaEnum = QMetaEnum::fromType<QLowEnergyController::Error>();
emit debug(QStringLiteral("thinkridercontroller::error") + QString::fromLocal8Bit(metaEnum.valueToKey(err)) +
m_control->errorString());
}
void thinkridercontroller::deviceDiscovered(const QBluetoothDeviceInfo &device) {
emit debug(QStringLiteral("Found new device: ") + device.name() + QStringLiteral(" (") +
device.address().toString() + ')');
{
bluetoothDevice = device;
m_control = QLowEnergyController::createCentral(bluetoothDevice, this);
connect(m_control, &QLowEnergyController::serviceDiscovered, this, &thinkridercontroller::serviceDiscovered);
connect(m_control, &QLowEnergyController::discoveryFinished, this, &thinkridercontroller::serviceScanDone);
connect(m_control,
static_cast<void (QLowEnergyController::*)(QLowEnergyController::Error)>(&QLowEnergyController::error),
this, &thinkridercontroller::error);
connect(m_control, &QLowEnergyController::stateChanged, this, &thinkridercontroller::controllerStateChanged);
connect(m_control,
static_cast<void (QLowEnergyController::*)(QLowEnergyController::Error)>(&QLowEnergyController::error),
this, [this](QLowEnergyController::Error error) {
Q_UNUSED(error);
Q_UNUSED(this);
emit debug(QStringLiteral("Cannot connect to remote device."));
emit disconnected();
});
connect(m_control, &QLowEnergyController::connected, this, [this]() {
Q_UNUSED(this);
emit debug(QStringLiteral("Controller connected. Search services..."));
m_control->discoverServices();
});
connect(m_control, &QLowEnergyController::disconnected, this, [this]() {
Q_UNUSED(this);
emit debug(QStringLiteral("LowEnergy controller disconnected"));
emit disconnected();
});
// Connect
m_control->connectToDevice();
return;
}
}
bool thinkridercontroller::connected() {
if (!m_control) {
return false;
}
return m_control->state() == QLowEnergyController::DiscoveredState;
}
void thinkridercontroller::controllerStateChanged(QLowEnergyController::ControllerState state) {
qDebug() << QStringLiteral("controllerStateChanged") << state;
if (state == QLowEnergyController::UnconnectedState) {
qDebug() << QStringLiteral("trying to connect back again...");
initDone = false;
if (m_control)
m_control->connectToDevice();
}
}

View File

@@ -0,0 +1,73 @@
#ifndef THINKRIDERCONTROLLER_H
#define THINKRIDERCONTROLLER_H
#include <QBluetoothDeviceDiscoveryAgent>
#include <QtBluetooth/qlowenergyadvertisingdata.h>
#include <QtBluetooth/qlowenergyadvertisingparameters.h>
#include <QtBluetooth/qlowenergycharacteristic.h>
#include <QtBluetooth/qlowenergycharacteristicdata.h>
#include <QtBluetooth/qlowenergycontroller.h>
#include <QtBluetooth/qlowenergydescriptordata.h>
#include <QtBluetooth/qlowenergyservice.h>
#include <QtBluetooth/qlowenergyservicedata.h>
#include <QtCore/qbytearray.h>
#ifndef Q_OS_ANDROID
#include <QtCore/qcoreapplication.h>
#else
#include <QtGui/qguiapplication.h>
#endif
#include <QtCore/qlist.h>
#include <QtCore/qmutex.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qtimer.h>
#include <QObject>
#include <QTime>
#include "devices/bluetoothdevice.h"
class thinkridercontroller : public bluetoothdevice {
Q_OBJECT
public:
thinkridercontroller(bluetoothdevice *parentDevice);
bool connected() override;
private:
// Thinkrider VS200 UUIDs
static const QBluetoothUuid SERVICE_UUID;
static const QBluetoothUuid CHARACTERISTIC_UUID;
// Button patterns
static const QByteArray SHIFT_UP_PATTERN;
static const QByteArray SHIFT_DOWN_PATTERN;
QList<QLowEnergyService *> gattCommunicationChannelService;
QLowEnergyCharacteristic gattNotifyCharacteristic;
bluetoothdevice *parentDevice = nullptr;
bool initDone = false;
signals:
void disconnected();
void debug(QString string);
void plus();
void minus();
public slots:
void deviceDiscovered(const QBluetoothDeviceInfo &device);
void disconnectBluetooth();
void serviceDiscovered(const QBluetoothUuid &gatt);
void serviceScanDone(void);
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
void stateChanged(QLowEnergyService::ServiceState state);
void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue);
void controllerStateChanged(QLowEnergyController::ControllerState state);
private slots:
void error(QLowEnergyController::Error err);
void errorService(QLowEnergyService::ServiceError);
};
#endif // THINKRIDERCONTROLLER_H

View File

@@ -391,6 +391,9 @@ bool GarminConnect::fetchCsrfToken()
bool GarminConnect::performLogin(const QString &email, const QString &password, bool suppressMfaSignal)
{
qDebug() << "GarminConnect: Performing login...";
qDebug() << "GarminConnect: Using domain:" << m_domain;
qDebug() << "GarminConnect: SSO URL:" << ssoUrl();
qDebug() << "GarminConnect: Connect API URL:" << connectApiUrl();
QString ssoEmbedUrl = ssoUrl() + SSO_EMBED_PATH;
@@ -452,15 +455,54 @@ bool GarminConnect::performLogin(const QString &email, const QString &password,
qDebug() << "GarminConnect: Login response length:" << response.length();
qDebug() << "GarminConnect: Response snippet:" << response.left(300);
// Check for success title (like Python garth library)
// Check page title (like Python garth library)
// garth checks ONLY the title for MFA detection, not the body
// This is important because some servers (like garmin.cn) may have "MFA" text
// in their Success page HTML body, which would cause false positives
QString pageTitle;
QRegularExpression titleRegex("<title>(.+?)</title>");
QRegularExpressionMatch titleMatch = titleRegex.match(response);
if (titleMatch.hasMatch()) {
QString title = titleMatch.captured(1);
qDebug() << "GarminConnect: Page title:" << title;
if (title == "Success") {
qDebug() << "GarminConnect: Login successful (Success page detected)";
pageTitle = titleMatch.captured(1);
qDebug() << "GarminConnect: Page title:" << pageTitle;
}
// Check if MFA is required by looking at the TITLE (garth approach)
// This is more reliable than checking the body which may contain "MFA" in scripts/URLs
if (pageTitle.contains("MFA", Qt::CaseInsensitive)) {
m_lastError = "MFA Required";
qDebug() << "GarminConnect: MFA detected in page title";
// Extract new CSRF token from MFA page - try multiple patterns
QRegularExpression csrfRegex1("name=\"_csrf\"[^>]*value=\"([^\"]+)\"");
QRegularExpression csrfRegex2("value=\"([^\"]+)\"[^>]*name=\"_csrf\"");
QRegularExpressionMatch match = csrfRegex1.match(response);
if (!match.hasMatch()) {
match = csrfRegex2.match(response);
}
if (match.hasMatch()) {
m_csrfToken = match.captured(1);
qDebug() << "GarminConnect: CSRF token from MFA page:" << m_csrfToken.left(20) << "...";
}
// Update cookies
m_cookies = m_manager->cookieJar()->cookiesForUrl(url);
if (!suppressMfaSignal) {
qDebug() << "GarminConnect: Emitting mfaRequired signal";
emit mfaRequired();
} else {
qDebug() << "GarminConnect: MFA required but signal suppressed (retrying with MFA code)";
}
reply->deleteLater();
return false;
}
// Check if login was successful (title is "Success")
if (pageTitle == "Success") {
qDebug() << "GarminConnect: Login successful (Success page detected)";
// Continue to extract ticket below
}
// Check for error messages in response
@@ -549,39 +591,17 @@ bool GarminConnect::performLogin(const QString &email, const QString &password,
return false;
}
// Check if MFA is required (legacy check for non-redirect MFA)
if (response.contains("MFA", Qt::CaseInsensitive) ||
response.contains("Enter MFA Code", Qt::CaseInsensitive)) {
m_lastError = "MFA Required";
qDebug() << "GarminConnect: MFA content detected in response";
// Extract new CSRF token from MFA page - try multiple patterns
QRegularExpression csrfRegex1("name=\"_csrf\"[^>]*value=\"([^\"]+)\"");
QRegularExpression csrfRegex2("value=\"([^\"]+)\"[^>]*name=\"_csrf\"");
QRegularExpressionMatch match = csrfRegex1.match(response);
if (!match.hasMatch()) {
match = csrfRegex2.match(response);
}
if (match.hasMatch()) {
m_csrfToken = match.captured(1);
}
// Update cookies
m_cookies = m_manager->cookieJar()->cookiesForUrl(url);
if (!suppressMfaSignal) {
emit mfaRequired();
}
reply->deleteLater();
return false;
}
// Extract ticket from response URL (already declared above)
if (responseUrl.isEmpty()) {
responseUrl = reply->url();
}
if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: Response URL:" << responseUrl.toString();
qDebug() << "GarminConnect: Response length:" << response.length();
qDebug() << "GarminConnect: Full response body:" << response;
}
QUrlQuery responseQuery(responseUrl);
QString ticket = responseQuery.queryItemValue("ticket");
@@ -599,6 +619,8 @@ bool GarminConnect::performLogin(const QString &email, const QString &password,
if (match.hasMatch()) {
ticket = match.captured(1);
qDebug() << "GarminConnect: Found ticket with fallback pattern:" << ticket.left(20) << "...";
} else if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: No ticket patterns matched in response body";
}
}
}
@@ -608,6 +630,9 @@ bool GarminConnect::performLogin(const QString &email, const QString &password,
if (ticket.isEmpty()) {
m_lastError = "Failed to extract ticket from login response";
qDebug() << "GarminConnect:" << m_lastError;
if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: Response snippet:" << response.left(1000);
}
return false;
}
@@ -708,8 +733,12 @@ void GarminConnect::handleMfaReplyFinished()
qDebug() << "GarminConnect: MFA response status code:" << statusCode;
qDebug() << "GarminConnect: MFA response redirect URL:" << responseUrl.toString();
// If no redirect, log response body to understand what happened
if (responseUrl.isEmpty()) {
// Log detailed response information
if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: MFA response length:" << response.length();
qDebug() << "GarminConnect: Full MFA response body:" << response;
} else if (responseUrl.isEmpty()) {
// If no redirect, log response body to understand what happened (non-verbose)
qDebug() << "GarminConnect: MFA response body (first 500 chars):" << response.left(500);
}
@@ -748,6 +777,9 @@ void GarminConnect::handleMfaReplyFinished()
// If not found in redirect URL, try response body
if (ticket.isEmpty() && !response.isEmpty()) {
if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: Attempting to extract ticket from MFA response body";
}
// Try multiple patterns for ticket extraction
QRegularExpression ticketRegex1("embed\\?ticket=([^\"]+)\"");
QRegularExpression ticketRegex2("ticket=([^&\"']+)");
@@ -761,6 +793,16 @@ void GarminConnect::handleMfaReplyFinished()
if (match.hasMatch()) {
ticket = match.captured(1);
qDebug() << "GarminConnect: Found ticket in response body (pattern 2):" << ticket.left(20) << "...";
} else if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: No MFA ticket patterns matched. Checking for other patterns...";
// Check for JSON format
if (response.contains("ticket")) {
qDebug() << "GarminConnect: Response contains 'ticket' keyword, may be JSON or different format";
}
// Check for common response patterns
if (response.contains("\"")) {
qDebug() << "GarminConnect: Response contains quoted strings (may be JSON)";
}
}
}
}
@@ -770,6 +812,9 @@ void GarminConnect::handleMfaReplyFinished()
if (ticket.isEmpty()) {
m_lastError = "Failed to extract ticket after MFA";
qDebug() << "GarminConnect:" << m_lastError;
if (DEBUG_GARMIN_VERBOSE) {
qDebug() << "GarminConnect: Response snippet:" << response.left(1000);
}
emit authenticationFailed(m_lastError);
return;
}
@@ -1401,6 +1446,7 @@ void GarminConnect::loadTokensFromSettings()
m_oauth1Token.oauth_token = settings.value(QZSettings::garmin_oauth1_token, QZSettings::default_garmin_oauth1_token).toString();
m_oauth1Token.oauth_token_secret = settings.value(QZSettings::garmin_oauth1_token_secret, QZSettings::default_garmin_oauth1_token_secret).toString();
m_domain = settings.value(QZSettings::garmin_domain, QZSettings::default_garmin_domain).toString();
qDebug() << "GarminConnect: Loaded Garmin domain from settings:" << m_domain;
if (!m_oauth2Token.access_token.isEmpty()) {
qDebug() << "GarminConnect: Loaded tokens from settings (OAuth1 + OAuth2)";

View File

@@ -176,6 +176,7 @@ private:
static constexpr const char* SSO_URL_PATH = "/sso/signin";
static constexpr const char* SSO_EMBED_PATH = "/sso/embed";
static constexpr const char* OAUTH_CONSUMER_URL = "https://thegarth.s3.amazonaws.com/oauth_consumer.json";
static constexpr bool DEBUG_GARMIN_VERBOSE = false; // Set to true for detailed response logging (may contain sensitive data)
// Private methods
QString ssoUrl() const { return QString("https://sso.%1").arg(m_domain); }

View File

@@ -5396,6 +5396,7 @@ void homeform::update() {
double stepCount = 0;
bool miles = settings.value(QZSettings::miles_unit, QZSettings::default_miles_unit).toBool();
bool weight_kg_unit = settings.value(QZSettings::weight_kg_unit, QZSettings::default_weight_kg_unit).toBool();
double ftpSetting = settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble();
double unit_conversion = 1.0;
double meter_feet_conversion = 1.0;
@@ -5679,7 +5680,7 @@ void homeform::update() {
datetime->setValue(formattedTime);
watts = bluetoothManager->device()->wattsMetricforUI();
watt->setValue(QString::number(watts, 'f', 0));
weightLoss->setValue(QString::number(miles ? bluetoothManager->device()->weightLoss() * 35.274
weightLoss->setValue(QString::number((miles && !weight_kg_unit) ? bluetoothManager->device()->weightLoss() * 35.274
: bluetoothManager->device()->weightLoss(),
'f', 2));

View File

@@ -71,13 +71,13 @@ viewer.trackedEntity = bike;
</body>
<body>
<div id="cesiumContainer" class="cesiumContainer"></div>
<div id="metricsContainer" style="position: absolute; bottom: 0px; right: 0px; width: 200px; height: 250px; touch-action: none; user-select: none;">
<div class="metrics" style="color: #FFFFFF; width: 100%; height: 100%; margin: 0; border-radius: 25px; border: 2px solid #73AD21; background: #73AD21; padding: 8px; box-sizing: border-box; overflow: hidden; position: relative;">
<div id="metricsContainer" style="position: absolute; bottom: 0px; right: 0px; width: 200px; height: 250px; touch-action: none; user-select: none; z-index: 1000;">
<div class="metrics" style="color: #FFFFFF; width: 100%; height: 100%; margin: 0; border-radius: 25px; border: 2px solid #73AD21; background: #73AD21; padding: 8px; box-sizing: border-box; overflow: hidden; position: relative; touch-action: none;">
<div id="metricsText" style="font-size: 12px; line-height: 1.4;">🏃Speed: 0.00<br>🚴Cadence:0<br>💓Heart:0<br>🔥Calories:0.0<br>📏Odometer:0.00<br>⚡Watt:0<br>Elapsed:0:00:00<br>📐Inclination:0.0<br>🧲Resistance:0<br>Altitude:0.0<br>Elevation:0.0</div>
<div id="resizeHandle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.5) 50%); cursor: nwse-resize; border-bottom-right-radius: 23px;"></div>
<div id="resizeHandle" style="position: absolute; bottom: 0; right: 0; width: 50px; height: 50px; background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.8) 50%); cursor: nwse-resize; border-bottom-right-radius: 23px; display: flex; align-items: flex-end; justify-content: flex-end; font-size: 24px; color: rgba(0,0,0,0.6); padding-bottom: 2px; padding-right: 4px;"></div>
</div>
</div>
<div style="border: 0px solid #aaa; border-radius: 10px; overflow: hidden; position:absolute; bottom: 0px; right: 150px; width=150px; height=75px"><canvas id="canvasChart" style="width=150px; height=75px; border-right: 0pt solid #ffff00;"></canvas></div>
<div id="chartContainer" style="border: 0px solid #aaa; border-radius: 10px; overflow: hidden; position:absolute; bottom: 0px; right: 150px; width=150px; height=75px; z-index: 999; touch-action: none;"><canvas id="canvasChart" style="width=150px; height=75px; border-right: 0pt solid #ffff00;"></canvas></div>
<script type="text/javascript">
let cameraComplete = true
let lastAzimuth = 0
@@ -325,12 +325,29 @@ console.error('Error is ' + err);
const container = document.getElementById('metricsContainer');
const resizeHandle = document.getElementById('resizeHandle');
const metricsText = document.getElementById('metricsText');
const chartContainer = document.getElementById('chartContainer');
let isDragging = false;
let isResizing = false;
let startX, startY, startLeft, startTop, startWidth, startHeight;
let resizeTimeout = null;
// Update chart position to follow metrics container
function updateChartPosition() {
// Position chart to the left of metrics container, aligned at bottom
const metricsLeft = container.offsetLeft;
const metricsTop = container.offsetTop;
const metricsHeight = container.offsetHeight;
const chartWidth = chartContainer.offsetWidth;
const chartHeight = chartContainer.offsetHeight;
// Position chart: 10px to the left of metrics, aligned at bottom
chartContainer.style.left = (metricsLeft - chartWidth - 10) + 'px';
chartContainer.style.top = (metricsTop + metricsHeight - chartHeight) + 'px';
chartContainer.style.right = 'auto';
chartContainer.style.bottom = 'auto';
}
// Load saved position and size
function loadState() {
const saved = localStorage.getItem('metricsContainerState');
@@ -343,6 +360,7 @@ console.error('Error is ' + err);
if (state.bottom !== undefined) container.style.bottom = state.bottom + 'px';
if (state.width) container.style.width = state.width + 'px';
if (state.height) container.style.height = state.height + 'px';
updateChartPosition();
updateFontSize();
} catch (e) {
console.error('Error loading metrics state:', e);
@@ -438,6 +456,18 @@ console.error('Error is ' + err);
return { x: e.clientX, y: e.clientY };
}
// Check if touch/click is in resize handle area (bottom-right 50x50px)
function isInResizeHandle(x, y) {
const rect = container.getBoundingClientRect();
const handleSize = 50;
return (
x >= rect.right - handleSize &&
x <= rect.right &&
y >= rect.bottom - handleSize &&
y <= rect.bottom
);
}
// Start dragging
function startDrag(e) {
if (isResizing) return;
@@ -449,6 +479,15 @@ console.error('Error is ' + err);
startTop = container.offsetTop;
container.style.right = 'auto';
container.style.bottom = 'auto';
// Add global listeners
document.addEventListener('mousemove', handleMove);
document.addEventListener('touchmove', handleMove, { passive: false });
document.addEventListener('mouseup', endDragOrResize);
document.addEventListener('touchend', endDragOrResize);
document.addEventListener('touchcancel', endDragOrResize);
e.stopPropagation();
e.preventDefault();
}
@@ -460,12 +499,25 @@ console.error('Error is ' + err);
startY = coords.y;
startWidth = container.offsetWidth;
startHeight = container.offsetHeight;
// Add global listeners
document.addEventListener('mousemove', handleMove);
document.addEventListener('touchmove', handleMove, { passive: false });
document.addEventListener('mouseup', endDragOrResize);
document.addEventListener('touchend', endDragOrResize);
document.addEventListener('touchcancel', endDragOrResize);
e.stopPropagation();
e.preventDefault();
}
// Handle move
function handleMove(e) {
// Only handle if we're actually dragging or resizing
if (!isDragging && !isResizing) {
return;
}
const coords = getCoordinates(e);
if (isDragging) {
@@ -473,6 +525,8 @@ console.error('Error is ' + err);
const deltaY = coords.y - startY;
container.style.left = (startLeft + deltaX) + 'px';
container.style.top = (startTop + deltaY) + 'px';
updateChartPosition();
e.stopPropagation();
e.preventDefault();
} else if (isResizing) {
const deltaX = coords.x - startX;
@@ -481,17 +535,34 @@ console.error('Error is ' + err);
const newHeight = Math.max(100, startHeight + deltaY);
container.style.width = newWidth + 'px';
container.style.height = newHeight + 'px';
updateChartPosition();
debouncedUpdateFontSize();
e.stopPropagation();
e.preventDefault();
}
}
// End drag or resize
function endDragOrResize(e) {
if (isDragging || isResizing) {
const wasDragging = isDragging;
const wasResizing = isResizing;
// Always reset state first
isDragging = false;
isResizing = false;
// Always remove listeners to prevent leaks
document.removeEventListener('mousemove', handleMove);
document.removeEventListener('touchmove', handleMove);
document.removeEventListener('mouseup', endDragOrResize);
document.removeEventListener('touchend', endDragOrResize);
document.removeEventListener('touchcancel', endDragOrResize);
// Only save state if we were actually dragging/resizing
if (wasDragging || wasResizing) {
saveState();
// If we were resizing, clear pending timeout and update immediately
if (isResizing) {
if (wasResizing) {
if (resizeTimeout) {
clearTimeout(resizeTimeout);
resizeTimeout = null;
@@ -499,31 +570,49 @@ console.error('Error is ' + err);
updateFontSize();
}
}
isDragging = false;
isResizing = false;
}
// Add event listeners for dragging (on container, but not on resize handle)
// Check if touch/click is inside container
function isInsideContainer(x, y) {
const rect = container.getBoundingClientRect();
return (
x >= rect.left &&
x <= rect.right &&
y >= rect.top &&
y <= rect.bottom
);
}
// Add event listeners for dragging/resizing on container
container.addEventListener('mousedown', function(e) {
if (e.target !== resizeHandle) startDrag(e);
const coords = getCoordinates(e);
// Double check we're actually inside the container
if (!isInsideContainer(coords.x, coords.y)) {
return;
}
if (isInResizeHandle(coords.x, coords.y)) {
startResize(e);
} else {
startDrag(e);
}
});
container.addEventListener('touchstart', function(e) {
if (e.target !== resizeHandle) startDrag(e);
});
// Add event listeners for resizing (on resize handle)
resizeHandle.addEventListener('mousedown', startResize);
resizeHandle.addEventListener('touchstart', startResize);
// Add global move and end listeners
document.addEventListener('mousemove', handleMove);
document.addEventListener('touchmove', handleMove, { passive: false });
document.addEventListener('mouseup', endDragOrResize);
document.addEventListener('touchend', endDragOrResize);
const coords = getCoordinates(e);
// Double check we're actually inside the container
if (!isInsideContainer(coords.x, coords.y)) {
return;
}
if (isInResizeHandle(coords.x, coords.y)) {
startResize(e);
} else {
startDrag(e);
}
}, { passive: false });
// Load saved state and set initial font size
loadState();
updateFontSize();
updateChartPosition();
})();
</script>
</body>

View File

@@ -103,6 +103,7 @@ SOURCES += \
$$PWD/devices/sportsplusrower/sportsplusrower.cpp \
$$PWD/devices/sportstechelliptical/sportstechelliptical.cpp \
$$PWD/devices/sramAXSController/sramAXSController.cpp \
$$PWD/devices/thinkridercontroller/thinkridercontroller.cpp \
$$PWD/devices/stairclimber.cpp \
$$PWD/devices/echelonstairclimber/echelonstairclimber.cpp \
$$PWD/devices/technogymbike/technogymbike.cpp \
@@ -380,6 +381,7 @@ HEADERS += \
$$PWD/devices/sportsplusrower/sportsplusrower.h \
$$PWD/devices/sportstechelliptical/sportstechelliptical.h \
$$PWD/devices/sramAXSController/sramAXSController.h \
$$PWD/devices/thinkridercontroller/thinkridercontroller.h \
$$PWD/devices/stairclimber.h \
$$PWD/devices/technogymbike/technogymbike.h \
$$PWD/devices/trxappgateusbelliptical/trxappgateusbelliptical.h \

View File

@@ -814,7 +814,7 @@ void qfit::save(const QString &filename, QList<SessionLine> session, BLUETOOTH_T
lapMesg.SetMessageIndex(lap_index++);
lapMesg.SetLapTrigger(FIT_LAP_TRIGGER_DISTANCE);
if (type == JUMPROPE)
lapMesg.SetRepetitionNum(session.at(i - 1).inclination);
lapMesg.SetRepetitionNum(lap_index);
lastLapTimer = sl.elapsedTime;
lastLapOdometer = sl.distance;

View File

@@ -92,6 +92,7 @@ const QString QZSettings::default_user_email = QLatin1String("");
const QString QZSettings::user_nickname = QStringLiteral("user_nickname");
const QString QZSettings::default_user_nickname = QStringLiteral("");
const QString QZSettings::miles_unit = QStringLiteral("miles_unit");
const QString QZSettings::weight_kg_unit = QStringLiteral("weight_kg_unit");
const QString QZSettings::pause_on_start = QStringLiteral("pause_on_start");
const QString QZSettings::treadmill_force_speed = QStringLiteral("treadmill_force_speed");
const QString QZSettings::pause_on_start_treadmill = QStringLiteral("pause_on_start_treadmill");
@@ -776,6 +777,7 @@ const QString QZSettings::proform_treadmill_505_cst = QStringLiteral("proform_tr
const QString QZSettings::nordictrack_treadmill_t8_5s = QStringLiteral("nordictrack_treadmill_t8_5s");
const QString QZSettings::proform_treadmill_705_cst = QStringLiteral("proform_treadmill_705_cst");
const QString QZSettings::zwift_click = QStringLiteral("zwift_click");
const QString QZSettings::thinkrider_controller = QStringLiteral("thinkrider_controller");
const QString QZSettings::hop_sport_hs_090h_bike = QStringLiteral("hop_sport_hs_090h_bike");
const QString QZSettings::zwift_play = QStringLiteral("zwift_play");
const QString QZSettings::zwift_play_vibration = QStringLiteral("zwift_play_vibration");
@@ -1050,7 +1052,7 @@ const QString QZSettings::trainprogram_auto_lap_on_segment = QStringLiteral("tra
const QString QZSettings::kingsmith_r2_enable_hw_buttons = QStringLiteral("kingsmith_r2_enable_hw_buttons");
const uint32_t allSettingsCount = 856;
const uint32_t allSettingsCount = 858;
QVariant allSettings[allSettingsCount][2] = {
{QZSettings::cryptoKeySettingsProfiles, QZSettings::default_cryptoKeySettingsProfiles},
@@ -1110,6 +1112,7 @@ QVariant allSettings[allSettingsCount][2] = {
{QZSettings::user_email, QZSettings::default_user_email},
{QZSettings::user_nickname, QZSettings::default_user_nickname},
{QZSettings::miles_unit, QZSettings::default_miles_unit},
{QZSettings::weight_kg_unit, QZSettings::default_weight_kg_unit},
{QZSettings::pause_on_start, QZSettings::default_pause_on_start},
{QZSettings::treadmill_force_speed, QZSettings::default_treadmill_force_speed},
{QZSettings::pause_on_start_treadmill, QZSettings::default_pause_on_start_treadmill},
@@ -1696,6 +1699,7 @@ QVariant allSettings[allSettingsCount][2] = {
{QZSettings::nordictrack_treadmill_t8_5s, QZSettings::default_nordictrack_treadmill_t8_5s},
{QZSettings::proform_treadmill_705_cst, QZSettings::default_proform_treadmill_705_cst},
{QZSettings::zwift_click, QZSettings::default_zwift_click},
{QZSettings::thinkrider_controller, QZSettings::default_thinkrider_controller},
{QZSettings::hop_sport_hs_090h_bike, QZSettings::default_hop_sport_hs_090h_bike},
{QZSettings::zwift_play, QZSettings::default_zwift_play},
{QZSettings::zwift_play_vibration, QZSettings::default_zwift_play_vibration},

View File

@@ -272,6 +272,12 @@ class QZSettings {
static const QString miles_unit;
static constexpr bool default_miles_unit = false;
/**
*@brief Use kg for weight even when miles_unit is true (for UK users).
*/
static const QString weight_kg_unit;
static constexpr bool default_weight_kg_unit = false;
static const QString pause_on_start;
static constexpr bool default_pause_on_start = false;
@@ -2140,6 +2146,9 @@ class QZSettings {
static const QString zwift_click;
static constexpr bool default_zwift_click = false;
static const QString thinkrider_controller;
static constexpr bool default_thinkrider_controller = false;
static const QString proform_treadmill_705_cst;
static constexpr bool default_proform_treadmill_705_cst = false;

View File

@@ -1273,6 +1273,8 @@ import Qt.labs.platform 1.1
property bool kingsmith_r2_enable_hw_buttons: false
property bool treadmill_direct_distance: false
property bool domyos_treadmill_ts100: false
property bool thinkrider_controller: false
property bool weight_kg_unit: false
}
@@ -1359,12 +1361,12 @@ import Qt.labs.platform 1.1
spacing: 10
Label {
id: labelWeight
text: qsTr("Player Weight") + "(" + (settings.miles_unit?"lbs":"kg") + ")"
text: qsTr("Player Weight") + "(" + ((settings.miles_unit && !settings.weight_kg_unit)?"lbs":"kg") + ")"
Layout.fillWidth: true
}
TextField {
id: weightTextField
text: (settings.miles_unit?settings.weight * 2.20462:settings.weight)
text: ((settings.miles_unit && !settings.weight_kg_unit)?settings.weight * 2.20462:settings.weight)
horizontalAlignment: Text.AlignRight
Layout.fillHeight: false
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
@@ -1376,11 +1378,11 @@ import Qt.labs.platform 1.1
id: okWeightButton
text: "OK"
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
onClicked: { settings.weight = (settings.miles_unit?weightTextField.text / 2.20462:weightTextField.text); toast.show("Setting saved!"); }
onClicked: { settings.weight = ((settings.miles_unit && !settings.weight_kg_unit)?weightTextField.text / 2.20462:weightTextField.text); toast.show("Setting saved!"); }
}
}
Label {
text: qsTr("Enter your weight in kilograms so QZ can more accurately calculate calories burned. NOTE: If you choose to use miles as the unit for distance traveled, you will be asked to enter your weight in pounds (lbs).")
text: qsTr("Enter your weight in kilograms so QZ can more accurately calculate calories burned. NOTE: If you choose to use miles as the unit for distance traveled, you will be asked to enter your weight in pounds (lbs) unless you enable 'Use kg for weight'.")
font.bold: true
font.italic: true
font.pixelSize: Qt.application.font.pixelSize - 2
@@ -1706,6 +1708,36 @@ import Qt.labs.platform 1.1
color: Material.color(Material.Lime)
}
IndicatorOnlySwitch {
id: weightKgUnitDelegate
text: qsTr("Use kg for weight")
spacing: 0
bottomPadding: 0
topPadding: 0
rightPadding: 0
leftPadding: 0
clip: false
checked: settings.weight_kg_unit
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
onClicked: settings.weight_kg_unit = checked
visible: settings.miles_unit
}
Label {
text: qsTr("Turn on if you want to use kilograms (kg) for weight instead of pounds (lbs). Useful for UK users who use miles for distance but kg for weight.")
font.bold: true
font.italic: true
font.pixelSize: Qt.application.font.pixelSize - 2
textFormat: Text.PlainText
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
color: Material.color(Material.Lime)
visible: settings.miles_unit
}
IndicatorOnlySwitch {
id: pauseOnStartDelegate
text: qsTr("Pause when App Starts")
@@ -2498,12 +2530,12 @@ import Qt.labs.platform 1.1
spacing: 10
Label {
id: labelBikeWeight
text: qsTr("Bike Weight") + "(" + (settings.miles_unit?"lbs":"kg") + ")"
text: qsTr("Bike Weight") + "(" + ((settings.miles_unit && !settings.weight_kg_unit)?"lbs":"kg") + ")"
Layout.fillWidth: true
}
TextField {
id: bikeweightTextField
text: (settings.miles_unit?settings.bike_weight * 2.20462:settings.bike_weight)
text: ((settings.miles_unit && !settings.weight_kg_unit)?settings.bike_weight * 2.20462:settings.bike_weight)
horizontalAlignment: Text.AlignRight
Layout.fillHeight: false
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
@@ -2515,12 +2547,12 @@ import Qt.labs.platform 1.1
id: okBikeWeightButton
text: "OK"
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
onClicked: { settings.bike_weight = (settings.miles_unit?bikeweightTextField.text / 2.20462:bikeweightTextField.text); toast.show("Setting saved!"); }
onClicked: { settings.bike_weight = ((settings.miles_unit && !settings.weight_kg_unit)?bikeweightTextField.text / 2.20462:bikeweightTextField.text); toast.show("Setting saved!"); }
}
}
Label {
text: qsTr("Enables QZ to include the weight of your bike when calculating speed. For example, if you are competing against yourself on VZfit, adding bike weight will level the playing field against your virtual self. If you have set QZ to calculate distance in miles, enter the bike weight in pounds (lbs). Default unit is kilograms (kgs).")
text: qsTr("Enables QZ to include the weight of your bike when calculating speed. For example, if you are competing against yourself on VZfit, adding bike weight will 'level the playing field' against your virtual self. If you have set QZ to calculate distance in miles, enter the bike weight in pounds (lbs) unless you enable 'Use kg for weight'. Default unit is kilograms (kgs).")
font.bold: true
font.italic: true
font.pixelSize: Qt.application.font.pixelSize - 2
@@ -6726,6 +6758,29 @@ import Qt.labs.platform 1.1
}
}
RowLayout {
spacing: 10
Label {
text: qsTr("Garmin Server:")
Layout.fillWidth: true
}
ComboBox {
id: garminServerComboBox
Layout.fillHeight: false
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
model: ["Global (garmin.com)", "China (garmin.cn)"]
currentIndex: settings.garmin_domain === "garmin.cn" ? 1 : 0
onCurrentIndexChanged: {
var newDomain = currentIndex === 1 ? "garmin.cn" : "garmin.com";
if (newDomain !== settings.garmin_domain) {
rootItem.garmin_connect_logout();
settings.garmin_domain = newDomain;
window.settings_restart_to_apply = true;
}
}
}
}
Button {
text: "Test Garmin Login"
Layout.alignment: Qt.AlignHCenter
@@ -12744,6 +12799,43 @@ import Qt.labs.platform 1.1
}
}*/
AccordionElement {
title: qsTr("Thinkrider Options")
indicatRectColor: Material.color(Material.Grey)
textColor: Material.color(Material.Yellow)
color: Material.backgroundColor
accordionContent: ColumnLayout {
spacing: 0
IndicatorOnlySwitch {
text: qsTr("Thinkrider Controller")
spacing: 0
bottomPadding: 0
topPadding: 0
rightPadding: 0
leftPadding: 0
clip: false
checked: settings.thinkrider_controller
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
onClicked: { settings.thinkrider_controller = checked; window.settings_restart_to_apply = true; }
}
Label {
text: qsTr("Thinkrider VS200 remote controller. Use it to change gears on QZ!")
font.bold: true
font.italic: true
font.pixelSize: Qt.application.font.pixelSize - 2
textFormat: Text.PlainText
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
color: Material.color(Material.Lime)
}
}
}
AccordionElement {
title: qsTr("Zwift Devices Options")
indicatRectColor: Material.color(Material.Grey)