From 06b4604e59b8b2635c7a7bd1240672e2a75f51c6 Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Thu, 24 Oct 2024 15:24:22 +0200 Subject: [PATCH] HOI Cross+ from Kettler #2694 --- src/devices/ypooelliptical/ypooelliptical.cpp | 21 +++++++++++-------- src/devices/ypooelliptical/ypooelliptical.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/devices/ypooelliptical/ypooelliptical.cpp b/src/devices/ypooelliptical/ypooelliptical.cpp index ab0adb2e5..c9035fdfe 100644 --- a/src/devices/ypooelliptical/ypooelliptical.cpp +++ b/src/devices/ypooelliptical/ypooelliptical.cpp @@ -79,7 +79,7 @@ void ypooelliptical::forceInclination(double inclination) { void ypooelliptical::forceResistance(resistance_t requestResistance) { - if(E35 || SCH_590E) { + if(E35 || SCH_590E || KETTLER) { uint8_t write[] = {FTMS_SET_TARGET_RESISTANCE_LEVEL, 0x00}; write[1] = ((uint16_t)requestResistance * 10) & 0xFF; writeCharacteristic(&gattFTMSWriteCharControlPointId, gattFTMSService, write, sizeof(write), @@ -108,7 +108,7 @@ void ypooelliptical::update() { if (initRequest) { initRequest = false; - if(E35 || SCH_590E) { + if(E35 || SCH_590E || KETTLER) { uint8_t write[] = {FTMS_REQUEST_CONTROL}; writeCharacteristic(&gattFTMSWriteCharControlPointId, gattFTMSService, write, sizeof(write), "requestControl", false, true); } else { @@ -250,7 +250,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara if (characteristic.uuid() == QBluetoothUuid((quint16)0x2ACE) && !iconsole_elliptical) { - if(E35 == false && SCH_590E == false) { + if(E35 == false && SCH_590E == false && KETTLER == false) { if (newvalue.length() == 18) { qDebug() << QStringLiteral("let's wait for the next piece of frame"); lastPacket = newvalue; @@ -270,7 +270,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara index += 3; if (!Flags.moreData) { - if(E35 || SCH_590E) { + if(E35 || SCH_590E || KETTLER) { Speed = ((double)(((uint16_t)((uint8_t)lastPacket.at(index + 1)) << 8) | (uint16_t)((uint8_t)lastPacket.at(index)))) / 100.0; @@ -282,7 +282,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara // this particular device, seems to send the actual speed here if (Flags.avgSpeed) { // double avgSpeed; - if(!E35 && !SCH_590E) { + if(!E35 && !SCH_590E && !KETTLER) { Speed = ((double)(((uint16_t)((uint8_t)lastPacket.at(index + 1)) << 8) | (uint16_t)((uint8_t)lastPacket.at(index)))) / 100.0; @@ -292,7 +292,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara } if (Flags.totDistance) { - if(!E35 && !SCH_590E) { + if(!E35 && !SCH_590E && !KETTLER) { Distance = ((double)((((uint32_t)((uint8_t)lastPacket.at(index + 2)) << 16) | (uint32_t)((uint8_t)lastPacket.at(index + 1)) << 8) | (uint32_t)((uint8_t)lastPacket.at(index)))) / @@ -314,7 +314,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara .toString() .startsWith(QStringLiteral("Disabled"))) { double divisor = 1.0; - if(E35 || SCH_590E) + if(E35 || SCH_590E || KETTLER) divisor = 2.0; Cadence = (((double)(((uint16_t)((uint8_t)lastPacket.at(index + 1)) << 8) | (uint16_t)((uint8_t)lastPacket.at(index))))) / divisor; @@ -382,7 +382,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara .startsWith(QStringLiteral("Disabled"))) { double divisor = 100.0; // i added this because this device seems to send it multiplied by 100 - if(E35 || SCH_590E) + if(E35 || SCH_590E || KETTLER) divisor = 1.0; m_watt = ((double)(((uint16_t)((uint8_t)lastPacket.at(index + 1)) << 8) | @@ -393,7 +393,7 @@ void ypooelliptical::characteristicChanged(const QLowEnergyCharacteristic &chara index += 2; } - if (Flags.avgPower && lastPacket.length() > index + 1 && !E35 && !SCH_590E) { // E35 has a bug about this + if (Flags.avgPower && lastPacket.length() > index + 1 && !E35 && !SCH_590E && !KETTLER) { // E35 has a bug about this double avgPower; avgPower = ((double)(((uint16_t)((uint8_t)lastPacket.at(index + 1)) << 8) | (uint16_t)((uint8_t)lastPacket.at(index)))); @@ -750,6 +750,9 @@ void ypooelliptical::deviceDiscovered(const QBluetoothDeviceInfo &device) { } else if(device.name().toUpper().startsWith(QStringLiteral("E35"))) { E35 = true; qDebug() << "E35 workaround ON!"; + } else if(device.name().toUpper().startsWith(QStringLiteral("KETTLER "))) { + KETTLER = true; + qDebug() << "KETTLER workaround ON!"; } m_control = QLowEnergyController::createCentral(bluetoothDevice, this); diff --git a/src/devices/ypooelliptical/ypooelliptical.h b/src/devices/ypooelliptical/ypooelliptical.h index 4fc0466d3..013162a6b 100644 --- a/src/devices/ypooelliptical/ypooelliptical.h +++ b/src/devices/ypooelliptical/ypooelliptical.h @@ -78,6 +78,7 @@ class ypooelliptical : public elliptical { uint8_t counterPoll = 0; bool SCH_590E = false; bool E35 = false; + bool KETTLER = false; #ifdef Q_OS_IOS lockscreen *h = 0;