Skip to content

Commit

Permalink
No connection to x22i #65
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Nov 10, 2023
1 parent b928be6 commit 91e5a1f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/nordictrackifitadbtreadmill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ nordictrackifitadbtreadmill::nordictrackifitadbtreadmill(bool noWriteResistance,
}
#endif

#ifdef Q_OS_ANDROID
if (nordictrack_ifit_adb_remote) {
#ifdef Q_OS_ANDROID
QAndroidJniObject IP = QAndroidJniObject::fromString(ip).object<jstring>();
QAndroidJniObject::callStaticMethod<void>("org/cagnulen/qdomyoszwift/QZAdbRemote", "createConnection",
"(Ljava/lang/String;Landroid/content/Context;)V",
IP.object<jstring>(), QtAndroid::androidContext().object());
}
#elif defined Q_OS_IOS
#ifndef IO_UNDER_QT
h->adb_connect(IP.toStdString().c_str());
#endif
#endif
}

initRequest = true;

Expand Down Expand Up @@ -219,7 +223,6 @@ void nordictrackifitadbtreadmill::processPendingDatagrams() {
}
}

#ifdef Q_OS_ANDROID
bool nordictrack_ifit_adb_remote =
settings.value(QZSettings::nordictrack_ifit_adb_remote, QZSettings::default_nordictrack_ifit_adb_remote)
.toBool();
Expand All @@ -233,9 +236,15 @@ void nordictrackifitadbtreadmill::processPendingDatagrams() {
lastCommand = "input swipe " + QString::number(x1) + " " + QString::number(y1Speed) + " " +
QString::number(x1) + " " + QString::number(y2) + " 200";
qDebug() << " >> " + lastCommand;
#ifdef Q_OS_ANDROID
QAndroidJniObject command = QAndroidJniObject::fromString(lastCommand).object<jstring>();
QAndroidJniObject::callStaticMethod<void>("org/cagnulen/qdomyoszwift/QZAdbRemote", "sendCommand",
"(Ljava/lang/String;)V", command.object<jstring>());
#elif defined Q_OS_IOS
#ifndef IO_UNDER_QT
h->adb_sendcommand(lastCommand.toStdString().c_str());
#endif
#endif
requestSpeed = -1;
} else if (requestInclination != -100) {
int x1 = 75;
Expand All @@ -246,13 +255,19 @@ void nordictrackifitadbtreadmill::processPendingDatagrams() {
lastCommand = "input swipe " + QString::number(x1) + " " + QString::number(y1Inclination) + " " +
QString::number(x1) + " " + QString::number(y2) + " 200";
qDebug() << " >> " + lastCommand;
#ifdef Q_OS_ANDROID
QAndroidJniObject command = QAndroidJniObject::fromString(lastCommand).object<jstring>();
QAndroidJniObject::callStaticMethod<void>("org/cagnulen/qdomyoszwift/QZAdbRemote", "sendCommand",
"(Ljava/lang/String;)V", command.object<jstring>());
#elif defined Q_OS_IOS
#ifndef IO_UNDER_QT
h->adb_sendcommand(lastCommand.toStdString().c_str());
#endif
#endif

requestInclination = -100;
}
}
#endif

QByteArray message = (QString::number(requestSpeed) + ";" + QString::number(requestInclination)).toLocal8Bit();
// we have to separate the 2 commands
Expand Down

0 comments on commit 91e5a1f

Please sign in to comment.