Compare commits

...

55 Commits

Author SHA1 Message Date
Roberto Viola
f8aa63d0d8 Update horizontreadmill.cpp 2024-12-10 15:01:55 +01:00
Roberto Viola
b573442800 Update qdomyos-zwift.pri 2024-11-21 13:00:17 +01:00
Roberto Viola
721f6d460e Update horizontreadmill.cpp 2024-11-21 12:14:25 +01:00
Roberto Viola
e6efe0f074 trying to use win11 api for discovery 2024-11-21 12:09:32 +01:00
Roberto Viola
df3e64e57d Revert "Update horizontreadmill.cpp"
This reverts commit e8faa3e671.
2024-11-14 09:04:42 +01:00
Roberto Viola
e8faa3e671 Update horizontreadmill.cpp 2024-11-13 12:14:37 +01:00
Roberto Viola
cc4a5be817 Merge branch 'master' into windows-11-crash-connecting 2024-11-13 10:43:26 +00:00
Roberto Viola
99394713f8 Update homeform.cpp 2024-11-12 12:06:05 +01:00
Roberto Viola
c76195a271 Update ftmsbike.cpp 2024-11-12 11:20:14 +01:00
Roberto Viola
79ba8ea874 Update horizontreadmill.cpp 2024-11-12 11:11:11 +01:00
Roberto Viola
f602563789 fixing android build 2024-11-12 11:00:51 +01:00
Roberto Viola
12f77be4a4 Merge branch 'zwift-hub-gear-custom' of https://github.com/cagnulein/qdomyos-zwift into zwift-hub-gear-custom 2024-11-12 10:46:48 +01:00
Roberto Viola
c5cfb1c936 Update project.pbxproj 2024-11-12 10:46:30 +01:00
Roberto Viola
a2e721812f Update main.cpp 2024-11-12 10:39:49 +01:00
Roberto Viola
f737e1be83 Merge branch 'master' into zwift-hub-gear-custom 2024-11-12 10:37:20 +01:00
Roberto Viola
eafe75e65f Update main.cpp 2024-11-12 10:24:46 +01:00
Roberto Viola
7c52e9263f Update main.cpp 2024-11-12 09:58:34 +01:00
Roberto Viola
9bb016f4b9 adding android part 2024-11-12 09:33:53 +01:00
Roberto Viola
797ae5f102 fixing mingears and maxgears 2024-11-12 09:10:14 +01:00
Roberto Viola
190011a365 reverting tacxneo wheel diameter and ftms standard wheel diamater in order to merge it 2024-11-12 09:07:02 +01:00
Roberto Viola
159f96dd8d Update project.pbxproj 2024-11-11 13:04:35 +01:00
Roberto Viola
839213e917 Update ftmsbike.cpp 2024-11-11 13:03:32 +01:00
Roberto Viola
e349ca9bad protobuf also for the gears 2024-11-11 11:10:11 +01:00
Roberto Viola
9ca3fca817 implemented protobuf 2024-11-11 09:04:48 +01:00
Roberto Viola
095d8bc1a3 Update ftmsbike.cpp 2024-11-09 20:27:18 +01:00
Roberto Viola
07606facba adding inclination custom message too 2024-11-09 18:49:48 +01:00
Roberto Viola
bd0e7033c2 Merge branch 'master' into zwift-hub-gear-custom 2024-11-09 18:42:47 +01:00
Roberto Viola
0337c08252 first custom gear test 2024-11-09 15:48:01 +01:00
Roberto Viola
8b60b56dc2 Update ftmsbike.cpp 2024-11-09 15:43:06 +01:00
Roberto Viola
f3d8b3964c Merge branch 'master' into tacx_wheel_diameter 2024-11-09 15:37:11 +01:00
Roberto Viola
06253998ee Update wahookickrsnapbike.cpp 2024-11-04 15:08:26 +01:00
Roberto Viola
dbb9ba3510 implementing 2024-11-04 14:31:58 +01:00
Roberto Viola
ad802f7d2d Merge branch 'master' into tacx_wheel_diameter 2024-11-04 14:28:42 +01:00
Roberto Viola
9cc02dede9 ftms wheel circumference for gears 2024-10-30 15:57:31 +01:00
Roberto Viola
82a6afe6b6 kickr core to wahookickr class 2024-10-29 12:28:13 +01:00
Roberto Viola
a7b8e63235 fixing UI and settings 2024-10-29 08:50:33 +01:00
Roberto Viola
d7c3a84adb adding max and minGears 2024-10-29 08:21:59 +01:00
Roberto Viola
64b9ec9d72 fixing gear conversion 2024-10-29 08:17:38 +01:00
Roberto Viola
379cf8d7de Update project.pbxproj 2024-10-29 08:02:08 +01:00
Roberto Viola
2f2989f90d completed? 2024-10-28 15:40:00 +01:00
Roberto Viola
6fac9770be qml finally saves the settings correctly 2024-10-28 15:09:13 +01:00
Roberto Viola
8d07d7c3f7 Merge branch 'master' into Custom-gearing-ranges/ratios-(Discussion-#2671) 2024-10-28 13:44:31 +01:00
Roberto Viola
f85f743499 i need to save the first 3 static objects and use it in the wahoo module 2024-10-28 11:11:05 +01:00
Roberto Viola
74c37f5624 Update gears.qml 2024-10-28 09:46:58 +01:00
Roberto Viola
527396eafc Revert "Update gears.qml"
This reverts commit 0f149448b3.
2024-10-28 09:18:54 +01:00
Roberto Viola
0f149448b3 Update gears.qml 2024-10-25 16:28:33 +02:00
Roberto Viola
ed1599ca8e need to center the values in the table 2024-10-24 15:08:25 +02:00
Roberto Viola
89808ae65b fixing casting to double 2024-10-24 11:15:51 +02:00
Roberto Viola
2da194f073 Merge branch 'master' into Custom-gearing-ranges/ratios-(Discussion-#2671) 2024-10-24 11:00:46 +02:00
Roberto Viola
d712621b7b fixing formula 2024-10-23 11:47:05 +02:00
Roberto Viola
1c06260036 Merge branch 'master' into Custom-gearing-ranges/ratios-(Discussion-#2671) 2024-10-23 11:44:26 +02:00
Roberto Viola
2d1364497e Update virtualbike_zwift.swift 2024-10-22 15:40:04 +02:00
Roberto Viola
cc7757bfcd Update project.pbxproj 2024-10-22 15:38:44 +02:00
Roberto Viola
49c7a96c81 Merge branch 'master' into Custom-gearing-ranges/ratios-(Discussion-#2671) 2024-10-22 15:32:50 +02:00
Roberto Viola
05d598ffcf first raw version 2024-10-21 14:06:48 +02:00
6 changed files with 233 additions and 13 deletions

View File

@@ -0,0 +1,74 @@
package org.cagnulen.qdomyoszwift;
import android.app.ActivityManager;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Looper;
import android.os.Handler;
import android.util.Log;
import com.garmin.android.connectiq.ConnectIQ;
import com.garmin.android.connectiq.ConnectIQAdbStrategy;
import com.garmin.android.connectiq.IQApp;
import com.garmin.android.connectiq.IQDevice;
import com.garmin.android.connectiq.exception.InvalidStateException;
import com.garmin.android.connectiq.exception.ServiceUnavailableException;
import android.content.BroadcastReceiver;
import android.content.ContextWrapper;
import android.content.IntentFilter;
import android.widget.Toast;
import org.jetbrains.annotations.Nullable;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.HashMap;
import java.util.List;
public class ZwiftHub {
private static Context context;
private static final String TAG = "ZwiftHub: ";
public static byte[] inclinationCommand(double inclination) throws InvalidProtocolBufferException {
SimulationParam.Builder simulation = SimulationParam.newBuilder();
simulation.setInclineX100((int)(inclination * 100.0));
HubCommand.Builder command = HubCommand.newBuilder();
command.setSimulation(simulation.build());
byte[] data = command.build().toByteArray();
byte[] fullData = new byte[data.length + 1];
fullData[0] = 0x04;
System.arraycopy(data, 0, fullData, 1, data.length);
return fullData;
}
public static byte[] setGearCommand(int gears) throws InvalidProtocolBufferException {
PhysicalParam.Builder physical = PhysicalParam.newBuilder();
physical.setGearRatioX10000(gears);
HubCommand.Builder command = HubCommand.newBuilder();
command.setPhysical(physical.build());
byte[] data = command.build().toByteArray();
byte[] fullData = new byte[data.length + 1];
fullData[0] = 0x04;
System.arraycopy(data, 0, fullData, 1, data.length);
return fullData;
}
}

View File

@@ -2311,6 +2311,82 @@ void horizontreadmill::characteristicRead(const QLowEnergyCharacteristic &charac
}
}
#ifdef Q_OS_WIN
bool horizontreadmill::discoverServicesWin11(const QBluetoothAddress& address) {
BLUETOOTH_DEVICE_INFO deviceInfo = { sizeof(BLUETOOTH_DEVICE_INFO) };
deviceInfo.Address.ullLong = address.toUInt64();
DWORD error = BluetoothGetDeviceInfo(nullptr, &deviceInfo);
if (error != ERROR_SUCCESS) {
qDebug() << "Failed to get device info. Error code:" << error;
DWORD lastError = GetLastError();
qDebug() << "Last error:" << lastError;
return false;
}
DWORD serviceCount = 0;
GUID* serviceGuids = nullptr;
// Prima chiamata per ottenere il numero di servizi
DWORD result = BluetoothEnumerateInstalledServices(
nullptr,
&deviceInfo,
&serviceCount,
nullptr);
if (result != ERROR_SUCCESS) {
qDebug() << "Failed to enumerate services count";
return false;
}
if (serviceCount == 0) {
qDebug() << "No services found";
return false;
}
// Allocare memoria per i GUID dei servizi
serviceGuids = new GUID[serviceCount];
// Seconda chiamata per ottenere i GUID effettivi
result = BluetoothEnumerateInstalledServices(
nullptr,
&deviceInfo,
&serviceCount,
serviceGuids);
if (result != ERROR_SUCCESS) {
delete[] serviceGuids;
qDebug() << "Failed to enumerate services";
return false;
}
// Processare ogni servizio trovato
for (DWORD i = 0; i < serviceCount; i++) {
handleWin11Service(serviceGuids[i]);
}
delete[] serviceGuids;
return true;
}
void horizontreadmill::handleWin11Service(const GUID& serviceGuid) {
wchar_t guidString[39];
StringFromGUID2(serviceGuid, guidString, sizeof(guidString)/sizeof(wchar_t));
QString qtGuidString = QString::fromWCharArray(guidString);
QBluetoothUuid qtUuid(qtGuidString);
QLowEnergyService* service = m_control->createServiceObject(qtUuid);
if (service) {
gattCommunicationChannelService.append(service);
connect(service, &QLowEnergyService::stateChanged, this, &horizontreadmill::stateChanged);
service->discoverDetails();
qDebug() << "Discovered service:" << qtUuid;
}
}
#endif
void horizontreadmill::serviceScanDone(void) {
emit debug(QStringLiteral("serviceScanDone"));
@@ -2318,12 +2394,18 @@ void horizontreadmill::serviceScanDone(void) {
firstStateChanged = 0;
auto services_list = m_control->services();
#ifdef Q_OS_WIN
if (discoverServicesWin11(m_control->remoteAddress())) {
return;
}
#endif
for (const QBluetoothUuid &s : qAsConst(services_list)) {
qDebug() << s << "discovering...";
gattCommunicationChannelService.append(m_control->createServiceObject(s));
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
&horizontreadmill::stateChanged);
gattCommunicationChannelService.constLast()->discoverDetails();
qDebug() << s << "discovering...";
gattCommunicationChannelService.append(m_control->createServiceObject(s));
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
&horizontreadmill::stateChanged);
gattCommunicationChannelService.constLast()->discoverDetails();
}
}

View File

@@ -34,6 +34,13 @@
#include "ios/lockscreen.h"
#endif
#ifdef Q_OS_WIN
#include <windows.h>
#include <bthsdpdef.h>
#include <bluetoothapis.h>
#include <VersionHelpers.h>
#endif
class horizontreadmill : public treadmill {
Q_OBJECT
public:
@@ -48,6 +55,11 @@ class horizontreadmill : public treadmill {
bool autoStartWhenSpeedIsGreaterThenZero() override;
private:
#ifdef Q_OS_WIN
bool discoverServicesWin11(const QBluetoothAddress& address);
void handleWin11Service(const GUID& serviceGuid);
#endif
void writeCharacteristic(QLowEnergyService *service, QLowEnergyCharacteristic characteristic, uint8_t *data,
uint8_t data_len, QString info, bool disable_log = false, bool wait_for_response = false);
void waitForAPacket();

View File

@@ -990,14 +990,15 @@ void homeform::backup() {
static uint8_t index = 0;
qDebug() << QStringLiteral("saving fit file backup...");
QString path = getWritableAppDir();
bluetoothdevice *dev = bluetoothManager->device();
if (dev) {
QString filename = path + QString::number(index) + backupFitFileName;
QFile::remove(filename);
qfit::save(filename, Session, dev->deviceType(),
qDebug() << QStringLiteral("writable dir") << path;
bluetoothdevice *dev = bluetoothManager->device();
if (dev) {
QString filename = path + QString::number(index) + backupFitFileName;
qDebug() << QStringLiteral("filename") << filename;
QFile::remove(filename);
qDebug() << QStringLiteral("filename removed") << filename;
qfit::save(filename, Session, dev->deviceType(),
qobject_cast<m3ibike *>(dev) ? QFIT_PROCESS_DISTANCENOISE : QFIT_PROCESS_NONE,
stravaPelotonWorkoutType, dev->bluetoothDevice.name());

View File

@@ -331,6 +331,50 @@ int main(int argc, char *argv[]) {
app->setOrganizationDomain(QStringLiteral("robertoviola.cloud"));
app->setApplicationName(QStringLiteral("qDomyos-Zwift"));
/* TEST ZWIFT HUB */
#ifdef Q_OS_ANDROID
{
QAndroidJniObject rrr = QAndroidJniObject::callStaticObjectMethod(
"org/cagnulen/qdomyoszwift/ZwiftHub",
"inclinationCommand",
"(D)[B",
8.0);
if(!rrr.isValid()) {
qDebug() << "inclinationCommand returned invalid value";
}
jbyteArray array = rrr.object<jbyteArray>();
QAndroidJniEnvironment env;
jbyte* bytes = env->GetByteArrayElements(array, nullptr);
jsize length = env->GetArrayLength(array);
QByteArray message((char*)bytes, length);
env->ReleaseByteArrayElements(array, bytes, JNI_ABORT);
qDebug() << "inclination command" << message.toHex(' ');
QAndroidJniObject rr = QAndroidJniObject::callStaticObjectMethod(
"org/cagnulen/qdomyoszwift/ZwiftHub",
"setGearCommand",
"(I)[B",
32608);
if (!rr.isValid()) {
qDebug() << "setGearCommand returned invalid value";
}
array = rr.object<jbyteArray>();
bytes = env->GetByteArrayElements(array, nullptr);
length = env->GetArrayLength(array);
QByteArray proto((char*)bytes, length);
env->ReleaseByteArrayElements(array, bytes, JNI_ABORT);
qDebug() << "gear command" << proto.toHex(' ');
}
#endif
QSettings settings;
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)

View File

@@ -31,7 +31,14 @@ CONFIG += qmltypes
#unix:!android: CONFIG += webengine
win32:DEFINES += _ITERATOR_DEBUG_LEVEL=0
win32:!mingw:LIBS += -llibprotobuf -llibprotoc -labseil_dll -llibprotobuf-lite -L$$PWD
win32:!mingw:LIBS += -llibprotobuf -llibprotoc -labseil_dll -llibprotobuf-lite -lBthprops -lVersion -lRpcrt4 -lole32 -L$$PWD
win32 {
LIBS += -lBthprops
LIBS += -lVersion
LIBS += -lRpcrt4 # Per StringFromGUID2
LIBS += -lole32 # Altra possibile dipendenza per GUID
}
QML_IMPORT_NAME = org.cagnulein.qdomyoszwift
QML_IMPORT_MAJOR_VERSION = 1