mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-18 00:17:41 +01:00
Compare commits
21 Commits
build-1035
...
fixing_tra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04d37e0a68 | ||
|
|
ae280e170a | ||
|
|
d2dfb16033 | ||
|
|
64d99748c7 | ||
|
|
16d90a010b | ||
|
|
32baab9072 | ||
|
|
31dd125263 | ||
|
|
483fd87ee5 | ||
|
|
254786ea5d | ||
|
|
c06a439c0c | ||
|
|
7b76999c0d | ||
|
|
5c0190dffe | ||
|
|
aabd2824d3 | ||
|
|
2f7033cd6d | ||
|
|
756fe823f8 | ||
|
|
b5890ea818 | ||
|
|
83627f5397 | ||
|
|
2b8af5d777 | ||
|
|
3f6b284468 | ||
|
|
1be9e2620d | ||
|
|
805981df4d |
@@ -413,6 +413,7 @@
|
||||
87958F1B27628D5400124B24 /* moc_elitesterzosmart.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87958F1A27628D5400124B24 /* moc_elitesterzosmart.cpp */; };
|
||||
8798C8872733E103003148B3 /* strydrunpowersensor.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 8798C8862733E103003148B3 /* strydrunpowersensor.cpp */; };
|
||||
8798C8892733E10E003148B3 /* moc_strydrunpowersensor.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 8798C8882733E10E003148B3 /* moc_strydrunpowersensor.cpp */; };
|
||||
8798FDC52D66075B00CF8EE8 /* OSXBtManagerInternal.mm in Compile Sources */ = {isa = PBXBuildFile; fileRef = 8798FDC32D66075B00CF8EE8 /* OSXBtManagerInternal.mm */; };
|
||||
879A38C8281BD83300F78B2A /* characteristicnotifier2ad9.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 879A38C7281BD83300F78B2A /* characteristicnotifier2ad9.cpp */; };
|
||||
879E5AA8289C057E00FEA38A /* proformwifitreadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 879E5AA6289C057E00FEA38A /* proformwifitreadmill.cpp */; };
|
||||
879E5AAA289C05A500FEA38A /* moc_proformwifitreadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 879E5AA9289C05A500FEA38A /* moc_proformwifitreadmill.cpp */; };
|
||||
@@ -1377,6 +1378,11 @@
|
||||
8798C8852733E103003148B3 /* strydrunpowersensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = strydrunpowersensor.h; path = ../src/devices/strydrunpowersensor/strydrunpowersensor.h; sourceTree = "<group>"; };
|
||||
8798C8862733E103003148B3 /* strydrunpowersensor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = strydrunpowersensor.cpp; path = ../src/devices/strydrunpowersensor/strydrunpowersensor.cpp; sourceTree = "<group>"; };
|
||||
8798C8882733E10E003148B3 /* moc_strydrunpowersensor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_strydrunpowersensor.cpp; sourceTree = "<group>"; };
|
||||
8798FDC02D66075B00CF8EE8 /* osxbluetooth_p.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = osxbluetooth_p.h; path = ../src/ios/BluetoothPatch/osxbluetooth_p.h; sourceTree = SOURCE_ROOT; };
|
||||
8798FDC12D66075B00CF8EE8 /* osxbtcentralmanager_p.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = osxbtcentralmanager_p.h; path = ../src/ios/BluetoothPatch/osxbtcentralmanager_p.h; sourceTree = SOURCE_ROOT; };
|
||||
8798FDC22D66075B00CF8EE8 /* osxbtgcdtimer_p.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = osxbtgcdtimer_p.h; path = ../src/ios/BluetoothPatch/osxbtgcdtimer_p.h; sourceTree = SOURCE_ROOT; };
|
||||
8798FDC32D66075B00CF8EE8 /* OSXBtManagerInternal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = OSXBtManagerInternal.mm; path = ../src/ios/BluetoothPatch/OSXBtManagerInternal.mm; sourceTree = SOURCE_ROOT; };
|
||||
8798FDC42D66075B00CF8EE8 /* osxbtutility_p.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = osxbtutility_p.h; path = ../src/ios/BluetoothPatch/osxbtutility_p.h; sourceTree = SOURCE_ROOT; };
|
||||
879A38C7281BD83300F78B2A /* characteristicnotifier2ad9.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = characteristicnotifier2ad9.cpp; path = ../src/characteristics/characteristicnotifier2ad9.cpp; sourceTree = "<group>"; };
|
||||
879E5AA6289C057E00FEA38A /* proformwifitreadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = proformwifitreadmill.cpp; path = ../src/devices/proformwifitreadmill/proformwifitreadmill.cpp; sourceTree = "<group>"; };
|
||||
879E5AA7289C057E00FEA38A /* proformwifitreadmill.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = proformwifitreadmill.h; path = ../src/devices/proformwifitreadmill/proformwifitreadmill.h; sourceTree = "<group>"; };
|
||||
@@ -2173,6 +2179,11 @@
|
||||
2EB56BE3C2D93CDAB0C52E67 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8798FDC02D66075B00CF8EE8 /* osxbluetooth_p.h */,
|
||||
8798FDC12D66075B00CF8EE8 /* osxbtcentralmanager_p.h */,
|
||||
8798FDC22D66075B00CF8EE8 /* osxbtgcdtimer_p.h */,
|
||||
8798FDC32D66075B00CF8EE8 /* OSXBtManagerInternal.mm */,
|
||||
8798FDC42D66075B00CF8EE8 /* osxbtutility_p.h */,
|
||||
87A33F1B2D611D9500BFFF29 /* logwriter.h */,
|
||||
87A33F1C2D611D9500BFFF29 /* logwriter.cpp */,
|
||||
87A33F192D611D8400BFFF29 /* moc_logwriter.cpp */,
|
||||
@@ -3758,6 +3769,7 @@
|
||||
872261F0289EA887006A6F75 /* moc_nordictrackelliptical.cpp in Compile Sources */,
|
||||
873824E327E647A8004F1B46 /* bitmap.cpp in Compile Sources */,
|
||||
87FE5BB12692F31E0056EFC8 /* moc_tacxneo2.cpp in Compile Sources */,
|
||||
8798FDC52D66075B00CF8EE8 /* OSXBtManagerInternal.mm in Compile Sources */,
|
||||
873824E827E647A8004F1B46 /* provider.cpp in Compile Sources */,
|
||||
8791A8AA25C8603F003B50B2 /* moc_inspirebike.cpp in Compile Sources */,
|
||||
03F49BBCF19B73B18385B13D /* FitMesgDefinition.mm in Compile Sources */,
|
||||
@@ -4243,7 +4255,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEVELOPMENT_TEAM = 6335M7T29D;
|
||||
ENABLE_BITCODE = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "ADB_HOST=1";
|
||||
@@ -4437,7 +4449,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = 6335M7T29D;
|
||||
ENABLE_BITCODE = NO;
|
||||
@@ -4667,7 +4679,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEVELOPMENT_TEAM = 6335M7T29D;
|
||||
ENABLE_BITCODE = YES;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
@@ -4763,7 +4775,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = 6335M7T29D;
|
||||
ENABLE_BITCODE = YES;
|
||||
@@ -4855,7 +4867,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
|
||||
ENABLE_BITCODE = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -4971,7 +4983,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1033;
|
||||
CURRENT_PROJECT_VERSION = 1035;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
|
||||
ENABLE_BITCODE = YES;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.cagnulen.qdomyoszwift" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:versionName="2.18.19" android:versionCode="1015" android:installLocation="auto">
|
||||
<manifest package="org.cagnulen.qdomyoszwift" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:versionName="2.18.20" android:versionCode="1020" android:installLocation="auto">
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
|
||||
@@ -1644,6 +1644,10 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
(b.name().toUpper().startsWith("T300P_")) ||
|
||||
(b.name().toUpper().startsWith("T200_")) ||
|
||||
(b.name().toUpper().startsWith("BZ9110 ")) ||
|
||||
(b.name().toUpper().startsWith("TITAN 7000")) ||
|
||||
(b.name().toUpper().startsWith("LYDSTO")) ||
|
||||
(b.name().toUpper().startsWith("CYCLO_")) ||
|
||||
(b.name().toUpper().startsWith("LCR")) ||
|
||||
(b.name().toUpper().startsWith(QStringLiteral("FIT-BK-"))) ||
|
||||
(b.name().toUpper().startsWith("VFSPINBIKE")) ||
|
||||
(b.name().toUpper().startsWith("GLT") && deviceHasService(b, QBluetoothUuid((quint16)0x1826))) ||
|
||||
|
||||
@@ -434,6 +434,8 @@ void ftmsbike::characteristicChanged(const QLowEnergyCharacteristic &characteris
|
||||
bool disable_hr_frommachinery =
|
||||
settings.value(QZSettings::heart_ignore_builtin, QZSettings::default_heart_ignore_builtin).toBool();
|
||||
bool heart = false;
|
||||
bool watt_ignore_builtin =
|
||||
settings.value(QZSettings::watt_ignore_builtin, QZSettings::default_watt_ignore_builtin).toBool();
|
||||
|
||||
qDebug() << characteristic.uuid() << newValue.length() << QStringLiteral(" << ") << newValue.toHex(' ');
|
||||
|
||||
@@ -616,6 +618,10 @@ void ftmsbike::characteristicChanged(const QLowEnergyCharacteristic &characteris
|
||||
// power table from an user
|
||||
if(DU30_bike) {
|
||||
m_watt = wattsFromResistance(Resistance.value());
|
||||
emit debug(QStringLiteral("Current Watt: ") + 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()));
|
||||
} else if (settings.value(QZSettings::power_sensor_name, QZSettings::default_power_sensor_name)
|
||||
.toString()
|
||||
.startsWith(QStringLiteral("Disabled")))
|
||||
@@ -1292,6 +1298,9 @@ void ftmsbike::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
} else if ((bluetoothDevice.name().toUpper().startsWith("SPAX-BK-"))) {
|
||||
qDebug() << QStringLiteral("SPAX-BK found");
|
||||
resistance_lvl_mode = true;
|
||||
} else if ((bluetoothDevice.name().toUpper().startsWith("LYDSTO"))) {
|
||||
qDebug() << QStringLiteral("LYDSTO found");
|
||||
LYDSTO = true;
|
||||
}
|
||||
|
||||
if(settings.value(QZSettings::force_resistance_instead_inclination, QZSettings::default_force_resistance_instead_inclination).toBool()) {
|
||||
|
||||
@@ -136,6 +136,7 @@ class ftmsbike : public bike {
|
||||
bool JFBK5_0 = false;
|
||||
bool BIKE_ = false;
|
||||
bool SMB1 = false;
|
||||
bool LYDSTO = false;
|
||||
|
||||
uint8_t battery_level = 0;
|
||||
|
||||
|
||||
@@ -1583,6 +1583,55 @@ void proformbike::characteristicChanged(const QLowEnergyCharacteristic &characte
|
||||
m_pelotonResistance = 100;
|
||||
break;
|
||||
}
|
||||
} else if (proform_xbike) {
|
||||
switch ((uint8_t)newValue.at(11)) {
|
||||
case 0x07:
|
||||
Resistance = 2;
|
||||
m_pelotonResistance = 25;
|
||||
break;
|
||||
case 0x0b:
|
||||
case 0x0c:
|
||||
Resistance = 3;
|
||||
m_pelotonResistance = 35;
|
||||
break;
|
||||
case 0x0f:
|
||||
Resistance = 4;
|
||||
m_pelotonResistance = 40;
|
||||
break;
|
||||
case 0x13:
|
||||
Resistance = 5;
|
||||
m_pelotonResistance = 50;
|
||||
break;
|
||||
case 0x17:
|
||||
Resistance = 6;
|
||||
m_pelotonResistance = 60;
|
||||
break;
|
||||
case 0x1a:
|
||||
case 0x1b:
|
||||
Resistance = 7;
|
||||
m_pelotonResistance = 65;
|
||||
break;
|
||||
case 0x1f:
|
||||
Resistance = 8;
|
||||
m_pelotonResistance = 75;
|
||||
break;
|
||||
case 0x23:
|
||||
case 0x24:
|
||||
Resistance = 9;
|
||||
m_pelotonResistance = 85;
|
||||
break;
|
||||
case 0x26:
|
||||
case 0x27:
|
||||
Resistance = 10;
|
||||
m_pelotonResistance = 100;
|
||||
break;
|
||||
/* when the proform bike is changing the resistance, it sends some strange values, so i'm keeping
|
||||
the last good one default: Resistance = 0; m_pelotonResistance = 0; break;
|
||||
*/
|
||||
default:
|
||||
Resistance = 1;
|
||||
m_pelotonResistance = 10;
|
||||
}
|
||||
} else if (!nordictrack_gx_2_7) {
|
||||
switch ((uint8_t)newValue.at(11)) {
|
||||
case 0x00:
|
||||
@@ -1909,7 +1958,7 @@ void proformbike::btinit() {
|
||||
writeCharacteristic(initData12, sizeof(initData12), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
} else if (settings.value(QZSettings::proform_xbike, QZSettings::default_proform_xbike).toBool()) {
|
||||
max_resistance = 25; // Most NordicTrack bikes use resistance range 1-25
|
||||
max_resistance = 10;
|
||||
|
||||
uint8_t initData1[] = {0xfe, 0x02, 0x08, 0x02};
|
||||
uint8_t initData2[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x81, 0x87,
|
||||
@@ -1940,6 +1989,27 @@ void proformbike::btinit() {
|
||||
uint8_t initData18[] = {0xff, 0x05, 0x00, 0x80, 0x01, 0x00, 0xa9, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t xbike_pkt582[] = {0xfe, 0x02, 0x17, 0x03};
|
||||
uint8_t xbike_pkt585[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x13, 0x07, 0x13, 0x02, 0x00, 0x0d, 0x00,
|
||||
0x10, 0x00, 0xc0, 0x1c, 0x4c, 0x00, 0x00, 0xe0};
|
||||
uint8_t xbike_pkt588[] = {0xff, 0x05, 0x00, 0x00, 0x00, 0x10, 0x51, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt594[] = {0xfe, 0x02, 0x17, 0x03};
|
||||
uint8_t xbike_pkt599[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x13, 0x07, 0x13, 0x02, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt602[] = {0xff, 0x05, 0x00, 0x80, 0x01, 0x00, 0xa9, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt607[] = {0xfe, 0x02, 0x17, 0x03};
|
||||
uint8_t xbike_pkt610[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x13, 0x07, 0x13, 0x02, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt613[] = {0xff, 0x05, 0x00, 0x80, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt618[] = {0xfe, 0x02, 0x17, 0x03};
|
||||
uint8_t xbike_pkt621[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x13, 0x07, 0x13, 0x02, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t xbike_pkt624[] = {0xff, 0x05, 0x00, 0x80, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
// The initialization sequence requires specific timing between messages
|
||||
writeCharacteristic(initData1, sizeof(initData1), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
@@ -1985,6 +2055,30 @@ void proformbike::btinit() {
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(initData18, sizeof(initData18), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt582, sizeof(xbike_pkt582), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt585, sizeof(xbike_pkt585), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt588, sizeof(xbike_pkt588), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt594, sizeof(xbike_pkt594), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt599, sizeof(xbike_pkt599), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt602, sizeof(xbike_pkt602), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt607, sizeof(xbike_pkt607), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt610, sizeof(xbike_pkt610), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt613, sizeof(xbike_pkt613), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt618, sizeof(xbike_pkt618), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt621, sizeof(xbike_pkt621), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
writeCharacteristic(xbike_pkt624, sizeof(xbike_pkt624), QStringLiteral("init"), false, false);
|
||||
QThread::msleep(400);
|
||||
} else if (settings.value(QZSettings::nordictrack_gx_44_pro, QZSettings::default_nordictrack_gx_44_pro).toBool()) {
|
||||
max_resistance = 25; // Most NordicTrack bikes use resistance range 1-25
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ void trxappgateusbbike::characteristicChanged(const QLowEnergyCharacteristic &ch
|
||||
double resistance = 0.0;
|
||||
double watt = 0.0;
|
||||
QTime now = QTime::currentTime();
|
||||
if (bike_type == FYTTER_RI08 || bike_type == FAL_SPORTS) {
|
||||
if (bike_type == FYTTER_RI08) {
|
||||
speed = cadence * 0.37407407407407407407407407407407;
|
||||
watt = GetWattFromPacketFytter(newValue);
|
||||
if (watt)
|
||||
@@ -247,7 +247,7 @@ void trxappgateusbbike::characteristicChanged(const QLowEnergyCharacteristic &ch
|
||||
(60000.0 / ((double)lastTimeCharChanged.msecsTo(
|
||||
now)))); //(( (0.048* Output in watts +1.19) *
|
||||
// body weight in kg * 3.5) / 200 ) / 60
|
||||
} else if (bike_type == TUNTURI || bike_type == TUNTURI_2) {
|
||||
} else if (bike_type == TUNTURI || bike_type == TUNTURI_2 || bike_type == FAL_SPORTS) {
|
||||
speed = cadence * 0.37407407407407407407407407407407;
|
||||
resistance = GetResistanceFromPacket(newValue);
|
||||
watt = GetWattFromPacket(newValue);
|
||||
|
||||
80
src/ios/BluetoothPatch/OSXBtManagerInternal.mm
Normal file
80
src/ios/BluetoothPatch/OSXBtManagerInternal.mm
Normal file
@@ -0,0 +1,80 @@
|
||||
#define QT_IOS_BLUETOOTH
|
||||
#import "osxbtcentralmanager_p.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
// Definizione della struttura dei membri privati
|
||||
@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) () {
|
||||
@package // Rende i membri accessibili alla categoria
|
||||
OSXBluetooth::CharHash charMap;
|
||||
OSXBluetooth::DescHash descMap;
|
||||
OSXBluetooth::ValueHash valuesToWrite;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(OSXBTCentralManager) (SafeCache)
|
||||
|
||||
- (bool)cacheWriteValue:(const QByteArray &)value for:(NSObject *)obj
|
||||
{
|
||||
@try {
|
||||
// Accesso alle variabili private tramite self
|
||||
OSXBluetooth::CharHash &localCharMap = ((QT_MANGLE_NAMESPACE(OSXBTCentralManager) *)self)->charMap;
|
||||
OSXBluetooth::DescHash &localDescMap = ((QT_MANGLE_NAMESPACE(OSXBTCentralManager) *)self)->descMap;
|
||||
OSXBluetooth::ValueHash &localValuesToWrite = ((QT_MANGLE_NAMESPACE(OSXBTCentralManager) *)self)->valuesToWrite;
|
||||
|
||||
// Verifica validità oggetto
|
||||
if (!obj) {
|
||||
qDebug() << "Error: Invalid object (nil)";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verifica tipo oggetto
|
||||
if ([obj isKindOfClass:[CBCharacteristic class]]) {
|
||||
@try {
|
||||
CBCharacteristic *const ch = (CBCharacteristic *)obj;
|
||||
if (!localCharMap.key(ch)) {
|
||||
qDebug() << "Error: Unexpected characteristic, no handle found";
|
||||
return false;
|
||||
}
|
||||
} @catch (NSException *e) {
|
||||
qDebug() << "Exception handling characteristic:" << e.reason;
|
||||
return false;
|
||||
}
|
||||
} else if ([obj isKindOfClass:[CBDescriptor class]]) {
|
||||
@try {
|
||||
CBDescriptor *const d = (CBDescriptor *)obj;
|
||||
if (!localDescMap.key(d)) {
|
||||
qDebug() << "Error: Unexpected descriptor, no handle found";
|
||||
return false;
|
||||
}
|
||||
} @catch (NSException *e) {
|
||||
qDebug() << "Exception handling descriptor:" << e.reason;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Error: Invalid object type, characteristic or descriptor required";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gestione cache esistente
|
||||
@try {
|
||||
if (localValuesToWrite.contains(obj)) {
|
||||
qDebug() << "Warning: Already has a cached value for this object, the value will be replaced";
|
||||
}
|
||||
|
||||
localValuesToWrite[obj] = value;
|
||||
} @catch (NSException *e) {
|
||||
qDebug() << "Exception during cache operation:" << e.reason;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} @catch (NSException *e) {
|
||||
qDebug() << "Unexpected exception in cacheWriteValue:" << e.reason;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
63
src/ios/BluetoothPatch/osxbluetooth_p.h
Normal file
63
src/ios/BluetoothPatch/osxbluetooth_p.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtBluetooth module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OSXBLUETOOTH_P_H
|
||||
#define OSXBLUETOOTH_P_H
|
||||
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <CoreBluetooth/CoreBluetooth.h>
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
#include <IOBluetooth/IOBluetooth.h>
|
||||
#endif
|
||||
|
||||
#endif // OSXBLUETOOTH_P_H
|
||||
176
src/ios/BluetoothPatch/osxbtcentralmanager_p.h
Normal file
176
src/ios/BluetoothPatch/osxbtcentralmanager_p.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtBluetooth module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OSXBTCENTRALMANAGER_P_H
|
||||
#define OSXBTCENTRALMANAGER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qlowenergycontroller.h"
|
||||
#include "qlowenergyservice.h"
|
||||
#include "osxbtgcdtimer_p.h"
|
||||
#include "qbluetoothuuid.h"
|
||||
#include "osxbtutility_p.h"
|
||||
#include "osxbluetooth_p.h"
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qqueue.h>
|
||||
#include <QtCore/qhash.h>
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
@class QT_MANGLE_NAMESPACE(OSXBTCentralManager);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QLowEnergyServicePrivate;
|
||||
|
||||
namespace OSXBluetooth {
|
||||
|
||||
class LECBManagerNotifier;
|
||||
|
||||
enum CentralManagerState
|
||||
{
|
||||
// QLowEnergyController already has some of these states,
|
||||
// but it's not enough and we need more special states here.
|
||||
CentralManagerIdle,
|
||||
// Required by CBCentralManager to avoid problems with dangled pointers.
|
||||
CentralManagerUpdating,
|
||||
CentralManagerConnecting,
|
||||
CentralManagerDiscovering,
|
||||
CentralManagerDisconnecting
|
||||
};
|
||||
|
||||
// In Qt we work with handles and UUIDs. Core Bluetooth
|
||||
// has NSArrays (and nested NSArrays inside servces/characteristics).
|
||||
// To simplify a navigation, I need a simple way to map from a handle
|
||||
// to a Core Bluetooth object. These are weak pointers,
|
||||
// will probably require '__weak' with ARC.
|
||||
typedef QHash<QLowEnergyHandle, CBService *> ServiceHash;
|
||||
typedef QHash<QLowEnergyHandle, CBCharacteristic *> CharHash;
|
||||
typedef QHash<QLowEnergyHandle, CBDescriptor *> DescHash;
|
||||
|
||||
// Descriptor/charactesirstic read/write requests
|
||||
// - we have to serialize 'concurrent' requests.
|
||||
struct LERequest {
|
||||
enum RequestType {
|
||||
CharRead,
|
||||
CharWrite,
|
||||
DescRead,
|
||||
DescWrite,
|
||||
ClientConfiguration,
|
||||
Invalid
|
||||
};
|
||||
|
||||
LERequest() : type(Invalid),
|
||||
withResponse(false),
|
||||
handle(0)
|
||||
{}
|
||||
|
||||
RequestType type;
|
||||
bool withResponse;
|
||||
QLowEnergyHandle handle;
|
||||
QByteArray value;
|
||||
};
|
||||
|
||||
typedef QQueue<LERequest> RequestQueue;
|
||||
|
||||
// Core Bluetooth's write confirmation does not provide
|
||||
// the updated value (characteristic or descriptor).
|
||||
// But the Qt's Bluetooth API ('write with response')
|
||||
// expects this updated value as a response, so we have
|
||||
// to cache this write value and report it back.
|
||||
// 'NSObject *' will require '__weak' with ARC.
|
||||
typedef QHash<NSObject *, QByteArray> ValueHash;
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) : NSObject<CBCentralManagerDelegate,
|
||||
CBPeripheralDelegate,
|
||||
QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
|
||||
- (id)initWith:(QT_PREPEND_NAMESPACE(OSXBluetooth)::LECBManagerNotifier *)notifier;
|
||||
- (void)dealloc;
|
||||
|
||||
- (CBPeripheral *)peripheral;
|
||||
|
||||
// IMPORTANT: _all_ these methods are to be executed on qt_LE_queue,
|
||||
// when passing parameters - C++ objects _must_ be copied (see the controller's code).
|
||||
- (void)connectToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)aDeviceUuid;
|
||||
|
||||
- (void)disconnectFromDevice;
|
||||
|
||||
- (void)discoverServices;
|
||||
- (void)discoverServiceDetails:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
|
||||
|
||||
- (void)setNotifyValue:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
|
||||
forCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
|
||||
onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
|
||||
|
||||
- (void)readCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
|
||||
onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
|
||||
|
||||
- (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
|
||||
charHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
|
||||
onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid
|
||||
withResponse:(bool)writeWithResponse;
|
||||
|
||||
- (void)readDescriptor:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle
|
||||
onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
|
||||
|
||||
- (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
|
||||
descHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle
|
||||
onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
|
||||
|
||||
- (void)detach;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
108
src/ios/BluetoothPatch/osxbtgcdtimer_p.h
Normal file
108
src/ios/BluetoothPatch/osxbtgcdtimer_p.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtBluetooth module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OSXBTGCDTIMER_P_H
|
||||
#define OSXBTGCDTIMER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "osxbtutility_p.h"
|
||||
|
||||
#include <QtCore/qelapsedtimer.h>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace OSXBluetooth {
|
||||
|
||||
enum class OperationTimeout
|
||||
{
|
||||
none,
|
||||
serviceDiscovery,
|
||||
includedServicesDiscovery,
|
||||
characteristicsDiscovery,
|
||||
characteristicRead,
|
||||
descriptorsDiscovery,
|
||||
descriptorRead,
|
||||
characteristicWrite
|
||||
};
|
||||
|
||||
} // namespace OSXBluetooth
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@protocol QT_MANGLE_NAMESPACE(GCDTimerDelegate)
|
||||
@required
|
||||
- (void)timeout:(id)sender;
|
||||
@end
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(OSXBTGCDTimer) : NSObject
|
||||
- (instancetype)initWithDelegate:(id<QT_MANGLE_NAMESPACE(GCDTimerDelegate)>)delegate;
|
||||
- (void)watchAfter:(id)object withTimeoutType:(QT_PREPEND_NAMESPACE(OSXBluetooth)::OperationTimeout)type;
|
||||
- (void)startWithTimeout:(qint64)ms step:(qint64)stepMS;
|
||||
- (void)handleTimeout;
|
||||
- (void)cancelTimer;
|
||||
- (id)objectUnderWatch;
|
||||
- (QT_PREPEND_NAMESPACE(OSXBluetooth)::OperationTimeout)timeoutType;
|
||||
@end
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace OSXBluetooth {
|
||||
|
||||
using GCDTimerObjC = QT_MANGLE_NAMESPACE(OSXBTGCDTimer);
|
||||
using GCDTimer = ObjCStrongReference<GCDTimerObjC>;
|
||||
|
||||
} // namespace OSXBluetooth
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // OSXBTGCDTIMER_P_H
|
||||
|
||||
336
src/ios/BluetoothPatch/osxbtutility_p.h
Normal file
336
src/ios/BluetoothPatch/osxbtutility_p.h
Normal file
@@ -0,0 +1,336 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtBluetooth module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OSXBTUTILITY_P_H
|
||||
#define OSXBTUTILITY_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "osxbluetooth_p.h"
|
||||
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QLowEnergyCharacteristicData;
|
||||
class QBluetoothAddress;
|
||||
class QBluetoothUuid;
|
||||
|
||||
namespace OSXBluetooth {
|
||||
|
||||
struct NSObjectDeleter {
|
||||
static void cleanup(NSObject *obj)
|
||||
{
|
||||
[obj release];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class ObjCScopedPointer : public QScopedPointer<NSObject, NSObjectDeleter>
|
||||
{
|
||||
public:
|
||||
// TODO: remove default argument, add 'retain' parameter,
|
||||
// add a default ctor??? This will make the semantics more
|
||||
// transparent + will simplify the future transition to ARC
|
||||
// (if it will ever happen).
|
||||
explicit ObjCScopedPointer(T *ptr = nullptr) : QScopedPointer(ptr){}
|
||||
operator T*() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
|
||||
T *data()const
|
||||
{
|
||||
return static_cast<T *>(QScopedPointer::data());
|
||||
}
|
||||
|
||||
T *take()
|
||||
{
|
||||
return static_cast<T *>(QScopedPointer::take());
|
||||
}
|
||||
};
|
||||
|
||||
#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool;
|
||||
|
||||
template<class T>
|
||||
class ObjCStrongReference {
|
||||
public:
|
||||
ObjCStrongReference()
|
||||
: m_ptr(nil)
|
||||
{
|
||||
}
|
||||
ObjCStrongReference(T *obj, bool retain)
|
||||
{
|
||||
if (retain)
|
||||
m_ptr = [obj retain];
|
||||
else
|
||||
m_ptr = obj; // For example, created with initWithXXXX.
|
||||
}
|
||||
ObjCStrongReference(const ObjCStrongReference &rhs)
|
||||
{
|
||||
m_ptr = [rhs.m_ptr retain];
|
||||
}
|
||||
ObjCStrongReference &operator = (const ObjCStrongReference &rhs)
|
||||
{
|
||||
// "Old-style" implementation:
|
||||
if (this != &rhs && m_ptr != rhs.m_ptr) {
|
||||
[m_ptr release];
|
||||
m_ptr = [rhs.m_ptr retain];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
ObjCStrongReference(ObjCStrongReference &&xval)
|
||||
{
|
||||
m_ptr = xval.m_ptr;
|
||||
xval.m_ptr = nil;
|
||||
}
|
||||
|
||||
ObjCStrongReference &operator = (ObjCStrongReference &&xval)
|
||||
{
|
||||
m_ptr = xval.m_ptr;
|
||||
xval.m_ptr = nil;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
~ObjCStrongReference()
|
||||
{
|
||||
[m_ptr release];
|
||||
}
|
||||
|
||||
void reset(T *newVal)
|
||||
{
|
||||
if (m_ptr != newVal) {
|
||||
[m_ptr release];
|
||||
m_ptr = [newVal retain];
|
||||
}
|
||||
}
|
||||
|
||||
void resetWithoutRetain(T *newVal)
|
||||
{
|
||||
if (m_ptr != newVal) {
|
||||
[m_ptr release];
|
||||
m_ptr = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
operator T *() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T *data() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T *take()
|
||||
{
|
||||
T * p = m_ptr;
|
||||
m_ptr = nil;
|
||||
return p;
|
||||
}
|
||||
private:
|
||||
T *m_ptr;
|
||||
};
|
||||
|
||||
// The type 'T' is some XXXRef from CoreFoundation and co.
|
||||
// In principle, we can do a trick removing a pointer from a type
|
||||
// when template is instantiated, but it's quite a lot of ugly pp-tokens
|
||||
// like OSXBluetooth::CFStrongReference<OSXBluetooth::remove_pointer<CFUUIDRref> > strongReference;
|
||||
// so instead we use 'T' everywhere, not 'T *' as can expected
|
||||
// from a smart pointer.
|
||||
template<class T>
|
||||
class CFStrongReference {
|
||||
public:
|
||||
CFStrongReference()
|
||||
: m_ptr(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
CFStrongReference(T obj, bool retain)
|
||||
: m_ptr(obj)
|
||||
{
|
||||
if (m_ptr && retain)
|
||||
CFRetain(m_ptr);
|
||||
}
|
||||
|
||||
CFStrongReference(const CFStrongReference &rhs)
|
||||
{
|
||||
if ((m_ptr = rhs.m_ptr))
|
||||
CFRetain(m_ptr);
|
||||
}
|
||||
|
||||
CFStrongReference &operator = (const CFStrongReference &rhs)
|
||||
{
|
||||
// "Old-style" implementation:
|
||||
if (this != &rhs && m_ptr != rhs.m_ptr) {
|
||||
if (m_ptr)
|
||||
CFRelease(m_ptr);
|
||||
if ((m_ptr = rhs.m_ptr))
|
||||
CFRetain(m_ptr);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
CFStrongReference(CFStrongReference &&xval)
|
||||
{
|
||||
m_ptr = xval.m_ptr;
|
||||
xval.m_ptr = nullptr;
|
||||
}
|
||||
|
||||
CFStrongReference &operator = (CFStrongReference &&xval)
|
||||
{
|
||||
m_ptr = xval.m_ptr;
|
||||
xval.m_ptr = nullptr;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
~CFStrongReference()
|
||||
{
|
||||
if (m_ptr)
|
||||
CFRelease(m_ptr);
|
||||
}
|
||||
|
||||
void reset(T newVal)
|
||||
{
|
||||
if (m_ptr != newVal) {
|
||||
if (m_ptr)
|
||||
CFRelease(m_ptr);
|
||||
if ((m_ptr = newVal))
|
||||
CFRetain(m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
operator T() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T data() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T take()
|
||||
{
|
||||
T p = m_ptr;
|
||||
m_ptr = nullptr;
|
||||
return p;
|
||||
}
|
||||
private:
|
||||
T m_ptr;
|
||||
};
|
||||
|
||||
QString qt_address(NSString *address);
|
||||
|
||||
#ifndef QT_IOS_BLUETOOTH
|
||||
|
||||
QBluetoothAddress qt_address(const BluetoothDeviceAddress *address);
|
||||
BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address);
|
||||
|
||||
ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid);
|
||||
QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid);
|
||||
QString qt_error_string(IOReturn errorCode);
|
||||
void qt_test_iobluetooth_runloop();
|
||||
|
||||
#endif // !QT_IOS_BLUETOOTH
|
||||
|
||||
QBluetoothUuid qt_uuid(CBUUID *uuid);
|
||||
CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid);
|
||||
ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid);
|
||||
bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid);
|
||||
bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid);
|
||||
QByteArray qt_bytearray(NSData *data);
|
||||
QByteArray qt_bytearray(NSObject *data);
|
||||
|
||||
ObjCStrongReference<NSData> data_from_bytearray(const QByteArray &qtData);
|
||||
ObjCStrongReference<NSMutableData> mutable_data_from_bytearray(const QByteArray &qtData);
|
||||
|
||||
dispatch_queue_t qt_LE_queue();
|
||||
|
||||
extern const int defaultLEScanTimeoutMS;
|
||||
extern const int maxValueLength;
|
||||
|
||||
} // namespace OSXBluetooth
|
||||
|
||||
// Logging category for both OS X and iOS.
|
||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_OSX)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(101300) && QT_MACOS_DEPLOYMENT_TARGET_BELOW(101300)
|
||||
|
||||
// In the macOS 10.13 SDK, the identifier property was moved from the CBPeripheral
|
||||
// and CBCentral classes to a new CBPeer base class. Because CBPeer is only available
|
||||
// on macOS 10.13 and above, the same is true for -[CBPeer identifier]. However,
|
||||
// since we know that the derived classes have always had this property,
|
||||
// we'll explicitly mark its availability here. This will not adversely affect
|
||||
// using the identifier through the CBPeer base class, which will still require macOS 10.13.
|
||||
|
||||
@interface CBPeripheral (UnguardedWorkaround)
|
||||
@property (readonly, nonatomic) NSUUID *identifier NS_AVAILABLE(10_7, 5_0);
|
||||
@end
|
||||
|
||||
@interface CBCentral (UnguardedWorkaround)
|
||||
@property (readonly, nonatomic) NSUUID *identifier NS_AVAILABLE(10_7, 5_0);
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -600,7 +600,7 @@ int main(int argc, char *argv[]) {
|
||||
qInstallMessageHandler(myMessageOutput);
|
||||
qDebug() << QStringLiteral("version ") << app->applicationVersion();
|
||||
foreach (QString s, settings.allKeys()) {
|
||||
if (!s.contains(QStringLiteral("password")) && !s.contains("user_email") && !s.contains("username")) {
|
||||
if (!s.contains(QStringLiteral("password")) && !s.contains("user_email") && !s.contains("username") && !s.contains("token")) {
|
||||
|
||||
qDebug() << s << settings.value(s);
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: "version 2.18.19"
|
||||
text: "version 2.18.20"
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
|
||||
@@ -673,6 +673,7 @@ void peloton::login_onfinish(QNetworkReply *reply) {
|
||||
|
||||
peloton_credentials_wrong = true;
|
||||
qDebug() << QStringLiteral("invalid peloton credentials during login ") << status;
|
||||
homeform::singleton()->setToastRequested("Peloton Auth Failed!");
|
||||
emit loginState(false);
|
||||
return;
|
||||
}
|
||||
@@ -2173,8 +2174,7 @@ void peloton::peloton_refreshtoken() {
|
||||
|
||||
// oops, no dice
|
||||
if (reply->error() != 0) {
|
||||
qDebug() << QStringLiteral("Got error") << reply->errorString().toStdString().c_str();
|
||||
homeform::singleton()->setToastRequested("Peloton Auth Failed!");
|
||||
qDebug() << QStringLiteral("Got error") << reply->errorString().toStdString().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -955,4 +955,4 @@ INCLUDEPATH += purchasing/inapp
|
||||
|
||||
WINRT_MANIFEST = AppxManifest.xml
|
||||
|
||||
VERSION = 2.18.19
|
||||
VERSION = 2.18.20
|
||||
|
||||
@@ -4,6 +4,7 @@ import QtQuick.Controls 2.15
|
||||
import QtQuick.Controls.Material 2.0
|
||||
import Qt.labs.settings 1.0
|
||||
import QtQuick.Dialogs 1.0
|
||||
import Qt.labs.platform 1.1
|
||||
|
||||
//Page {
|
||||
ScrollView {
|
||||
@@ -5066,6 +5067,20 @@ import QtQuick.Dialogs 1.0
|
||||
color: Material.color(Material.Lime)
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: zwiftPlaySettingsDialog
|
||||
text: "Zwift Play & Click Settings"
|
||||
informativeText: "Would you like to disable Zwift Play and Zwift Click settings? Having them enabled together with 'Get gears from Zwift' may cause conflicts."
|
||||
buttons: (MessageDialog.Yes | MessageDialog.No)
|
||||
onYesClicked: {
|
||||
settings.zwift_play = false;
|
||||
settings.zwift_click = false;
|
||||
settings.zwift_play_emulator = true;
|
||||
window.settings_restart_to_apply = true;
|
||||
}
|
||||
visible: false
|
||||
}
|
||||
|
||||
IndicatorOnlySwitch {
|
||||
text: qsTr("Get Gears from Zwift")
|
||||
spacing: 0
|
||||
@@ -5077,7 +5092,16 @@ import QtQuick.Dialogs 1.0
|
||||
checked: settings.zwift_play_emulator
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillWidth: true
|
||||
onClicked: { settings.zwift_play_emulator = checked; if(checked) { settings.watt_bike_emulator = false; } window.settings_restart_to_apply = true; }
|
||||
onClicked: {
|
||||
if (checked && !settings.zwift_play_emulator) { // Only show dialog when enabling
|
||||
if (settings.zwift_play || settings.zwift_click) {
|
||||
zwiftPlaySettingsDialog.visible = true;
|
||||
}
|
||||
settings.watt_bike_emulator = false;
|
||||
}
|
||||
window.settings_restart_to_apply = true;
|
||||
settings.zwift_play_emulator = checked;
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
|
||||
@@ -586,6 +586,17 @@ void trainprogram::scheduler() {
|
||||
|
||||
QMutexLocker(&this->schedulerMutex);
|
||||
QSettings settings;
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
qint64 msecsElapsed = lastSchedulerCall.msecsTo(now);
|
||||
|
||||
// Reset jitter if it's getting too large
|
||||
if (qAbs(currentTimerJitter) > 5000) {
|
||||
currentTimerJitter = 0;
|
||||
}
|
||||
|
||||
currentTimerJitter += msecsElapsed - 1000;
|
||||
lastSchedulerCall = now;
|
||||
|
||||
// outside the if case about a valid train program because the information for the floating window url should be
|
||||
// sent anyway
|
||||
if (settings.value(QZSettings::peloton_companion_workout_ocr, QZSettings::default_companion_peloton_workout_ocr)
|
||||
@@ -811,6 +822,7 @@ void trainprogram::scheduler() {
|
||||
#endif
|
||||
}
|
||||
|
||||
currentTimerJitter = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -832,6 +844,20 @@ void trainprogram::scheduler() {
|
||||
#endif
|
||||
|
||||
ticks++;
|
||||
qDebug() << QStringLiteral("trainprogram ticks") << ticks << QStringLiteral("currentTimerJitter") << currentTimerJitter;
|
||||
|
||||
if(qAbs(currentTimerJitter) > 1000) {
|
||||
// we are late...
|
||||
if (currentTimerJitter > 1000) {
|
||||
int seconds = currentTimerJitter / 1000;
|
||||
ticks += seconds;
|
||||
currentTimerJitter -= (seconds * 1000);
|
||||
qDebug() << QStringLiteral("fixing jitter!") << seconds << ticks << currentTimerJitter;
|
||||
} else {
|
||||
// negative jitter, reset the counter without touching the ticks
|
||||
currentTimerJitter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
double odometerFromTheDevice = bluetoothManager->device()->odometer();
|
||||
|
||||
@@ -1270,6 +1296,7 @@ void trainprogram::restart() {
|
||||
ticks = 0;
|
||||
offset = 0;
|
||||
currentStep = 0;
|
||||
currentTimerJitter = 0;
|
||||
started = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,9 @@ private slots:
|
||||
int lastStepTimestampChanged = 0;
|
||||
double lastCurrentStepDistance = 0.0;
|
||||
QTime lastCurrentStepTime = QTime(0, 0, 0);
|
||||
|
||||
int64_t currentTimerJitter = 0;
|
||||
QDateTime lastSchedulerCall = QDateTime::currentDateTime();
|
||||
|
||||
QUdpSocket* pelotonOCRsocket = nullptr;
|
||||
void pelotonOCRcomputeTime(QString t);
|
||||
|
||||
Reference in New Issue
Block a user