Compare commits

...

4 Commits

Author SHA1 Message Date
Roberto Viola
80387dbab4 Update wahookickrsnapbike.cpp 2024-11-26 09:21:57 +01:00
Roberto Viola
fd5896345e trying to clean the init 2024-11-25 16:58:35 +01:00
Roberto Viola
d2f9417380 trying to avoid to send always the same slope if it doesn's change and wait for the reply 2024-11-21 08:06:20 +01:00
Roberto Viola
bb2579bae1 Disable write no response for zwift play hub 2024-11-19 22:20:32 +01:00
3 changed files with 16 additions and 30 deletions

View File

@@ -63,10 +63,13 @@ void ftmsbike::writeCharacteristicZwiftPlay(uint8_t *data, uint8_t data_len, con
}
writeBuffer = new QByteArray((const char *)data, data_len);
#ifndef Q_OS_ANDROID
if (zwiftPlayWriteChar.properties() & QLowEnergyCharacteristic::WriteNoResponse) {
zwiftPlayService->writeCharacteristic(zwiftPlayWriteChar, *writeBuffer,
QLowEnergyService::WriteWithoutResponse);
} else {
QLowEnergyService::WriteWithoutResponse);
} else
#endif
{
zwiftPlayService->writeCharacteristic(zwiftPlayWriteChar, *writeBuffer);
}
@@ -146,9 +149,6 @@ void ftmsbike::zwiftPlayInit() {
uint8_t init1[] = {0x41, 0x08, 0x05};
writeCharacteristicZwiftPlay(init1, sizeof(init1), "init1", false, true);
uint8_t init2[] = {0x04, 0x2a, 0x04, 0x10, 0xc0, 0xbb, 0x01};
writeCharacteristicZwiftPlay(init2, sizeof(init2), "init2", false, true);
uint8_t init3[] = {0x00, 0x08, 0x00};
writeCharacteristicZwiftPlay(init3, sizeof(init3), "init3", false, true);
@@ -157,23 +157,8 @@ void ftmsbike::zwiftPlayInit() {
uint8_t init4[] = {0x00, 0x08, 0x88, 0x04};
writeCharacteristicZwiftPlay(init4, sizeof(init4), "init4", false, true);
uint8_t init5[] = {0x04, 0x2a, 0x0a, 0x10, 0xc0, 0xbb, 0x01, 0x20, 0xbf, 0x06, 0x28, 0xb4, 0x42};
uint8_t init5[] = {0x04, 0x2a, 0x0a, 0x10, 0xc0, 0xbb, 0x01, 0x20, 0xbf, 0x06, 0x28, 0xb4, 0x42}; //ok with power target 0
writeCharacteristicZwiftPlay(init5, sizeof(init5), "init5", false, true);
uint8_t init6[] = {0x04, 0x22, 0x0b, 0x08, 0x00, 0x10, 0xda, 0x02, 0x18, 0xec, 0x27, 0x20, 0x90, 0x03};
writeCharacteristicZwiftPlay(init6, sizeof(init6), "init6", false, true);
writeCharacteristicZwiftPlay(init2, sizeof(init2), "init2", false, true);
writeCharacteristicZwiftPlay(init4, sizeof(init4), "init4", false, true);
uint8_t init7[] = {0x04, 0x22, 0x03, 0x10, 0xa9, 0x01};
writeCharacteristicZwiftPlay(init7, sizeof(init7), "init7", false, true);
writeCharacteristicZwiftPlay(init2, sizeof(init2), "init2", false, true);
writeCharacteristicZwiftPlay(init4, sizeof(init4), "init4", false, true);
uint8_t init8[] = {0x04, 0x22, 0x02, 0x10, 0x00};
writeCharacteristicZwiftPlay(init8, sizeof(init8), "init8", false, true);
}
}
@@ -1068,7 +1053,14 @@ void ftmsbike::ftmsCharacteristicChanged(const QLowEnergyCharacteristic &charact
qDebug() << "implement zwift hub protobuf!";
return;
#endif
writeCharacteristicZwiftPlay((uint8_t*)message.data(), message.length(), "gearInclination", false, false);
if(lastSlope == slope) {
qDebug() << "grade is already set to " << slope << "skipping";
return;
}
lastSlope = slope;
writeCharacteristicZwiftPlay((uint8_t*)message.data(), message.length(), "gearInclination", false, true);
return;
} else if(b.at(0) == FTMS_SET_TARGET_POWER && zwiftPlayService != nullptr) {
qDebug() << "discarding";

View File

@@ -129,6 +129,8 @@ class ftmsbike : public bike {
uint8_t battery_level = 0;
int16_t lastSlope = 0;
#ifdef Q_OS_IOS
lockscreen *h = 0;
#endif

View File

@@ -736,14 +736,6 @@ void wahookickrsnapbike::serviceScanDone(void) {
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
&wahookickrsnapbike::stateChanged);
gattCommunicationChannelService.constLast()->discoverDetails();
if(s == QBluetoothUuid(QStringLiteral("00000001-19ca-4651-86e5-fa29dcdd09d1"))) {
QSettings settings;
settings.setValue(QZSettings::ftms_bike, bluetoothDevice.name());
settings.sync();
if(homeform::singleton())
homeform::singleton()->setToastRequested("Zwift Hub device found, please restart the app to enjoy virtual gearing!");
return;
}
}
}