Skip to content

Commit

Permalink
HOI Cross+ from Kettler #2694
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Oct 24, 2024
1 parent a6fd6b7 commit 06b4604
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/devices/ypooelliptical/ypooelliptical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)))) /
Expand All @@ -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;
Expand Down Expand Up @@ -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) |
Expand All @@ -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))));
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/devices/ypooelliptical/ypooelliptical.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06b4604

Please sign in to comment.