Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/devices/echelonrower/echelonrower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ double echelonrower::bikeResistanceToPeloton(double resistance) {

void echelonrower::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newvalue) {
// qDebug() << "characteristicChanged" << characteristic.uuid() << newValue << newValue.length();
Q_UNUSED(characteristic);
QSettings settings;
QString heartRateBeltName =
settings.value(QZSettings::heart_rate_belt_name, QZSettings::default_heart_rate_belt_name).toString();

qDebug() << QStringLiteral(" << ") + newvalue.toHex(' ');

if (auto *virtualRower = dynamic_cast<virtualrower *>(VirtualDevice())) {
virtualRower->relayEchelonPacket(characteristic.uuid(), newvalue);
}

if (lastPacket.count() > 0 && lastPacket.count() + newvalue.count() == 21 && ((unsigned char)lastPacket.at(0)) == 0xf0) {
lastPacket = lastPacket.append(newvalue);
qDebug() << QStringLiteral(" << concatenated ") + lastPacket.toHex(' ');
Expand Down Expand Up @@ -284,7 +287,9 @@ void echelonrower::characteristicChanged(const QLowEnergyCharacteristic &charact
settings.value(QZSettings::ios_peloton_workaround, QZSettings::default_ios_peloton_workaround).toBool();
bool virtual_device_rower =
settings.value(QZSettings::virtual_device_rower, QZSettings::default_virtual_device_rower).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower && h && firstStateChanged) {
bool virtual_device_echelon =
settings.value(QZSettings::virtual_device_echelon, QZSettings::default_virtual_device_echelon).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower && h && firstStateChanged && !virtual_device_echelon) {
h->virtualbike_setCadence(currentCrankRevolutions(), lastCrankEventTime());
h->virtualbike_setHeartRate((uint8_t)metrics_override_heartrate());
}
Expand Down Expand Up @@ -397,7 +402,9 @@ void echelonrower::stateChanged(QLowEnergyService::ServiceState state) {
settings.value(QZSettings::bike_cadence_sensor, QZSettings::default_bike_cadence_sensor).toBool();
bool ios_peloton_workaround =
settings.value(QZSettings::ios_peloton_workaround, QZSettings::default_ios_peloton_workaround).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower) {
bool virtual_device_echelon =
settings.value(QZSettings::virtual_device_echelon, QZSettings::default_virtual_device_echelon).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower && !virtual_device_echelon) {
qDebug() << "ios_peloton_workaround activated!";
h = new lockscreen();
h->virtualbike_ios();
Expand Down Expand Up @@ -508,6 +515,17 @@ bool echelonrower::connected() {
return m_control->state() == QLowEnergyController::DiscoveredState;
}

void echelonrower::proxyVirtualRowerCommand(const QByteArray &value) {
if (!gattCommunicationChannelService || !gattWriteCharacteristic.isValid() || !m_control ||
m_control->state() == QLowEnergyController::UnconnectedState) {
qDebug() << QStringLiteral("proxyVirtualRowerCommand ignored because the Echelon rower is not ready");
return;
}

writeCharacteristic(reinterpret_cast<uint8_t *>(const_cast<char *>(value.constData())), value.size(),
QStringLiteral("virtual echelon rower proxy"));
}

uint16_t echelonrower::watts() {
if (currentCadence().value() == 0) {
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/devices/echelonrower/echelonrower.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class echelonrower : public rower {
resistance_t resistanceFromPowerRequest(uint16_t power) override;
resistance_t maxResistance() override{ return max_resistance; }
bool connected() override;
void proxyVirtualRowerCommand(const QByteArray &value);

private:
const resistance_t max_resistance = 32;
Expand Down
16 changes: 15 additions & 1 deletion src/devices/echelonstride/echelonstride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ void echelonstride::characteristicChanged(const QLowEnergyCharacteristic &charac
QSettings settings;
QString heartRateBeltName =
settings.value(QZSettings::heart_rate_belt_name, QZSettings::default_heart_rate_belt_name).toString();
Q_UNUSED(characteristic);
QByteArray value = newValue;

qDebug() << QStringLiteral(" << ") + newValue.toHex(' ');

if (auto *virtualTreadmill = dynamic_cast<virtualtreadmill *>(VirtualDevice())) {
virtualTreadmill->relayEchelonPacket(characteristic.uuid(), newValue);
}

lastPacket = newValue;

if (((unsigned char)newValue.at(0)) == 0xf0 && ((unsigned char)newValue.at(1)) == 0xd3) {
Expand Down Expand Up @@ -533,6 +536,17 @@ bool echelonstride::connected() {
return m_control->state() == QLowEnergyController::DiscoveredState;
}

void echelonstride::proxyVirtualTreadmillCommand(const QByteArray &value) {
if (!gattCommunicationChannelService || !gattWriteCharacteristic.isValid() || !m_control ||
m_control->state() == QLowEnergyController::UnconnectedState) {
qDebug() << QStringLiteral("proxyVirtualTreadmillCommand ignored because the Echelon treadmill is not ready");
return;
}

writeCharacteristic(reinterpret_cast<uint8_t *>(const_cast<char *>(value.constData())), value.size(),
QStringLiteral("virtual echelon treadmill proxy"));
}

bool echelonstride::autoPauseWhenSpeedIsZero() {
if (lastStart == 0 || QDateTime::currentMSecsSinceEpoch() > (lastStart + 10000))
return true;
Expand Down
1 change: 1 addition & 0 deletions src/devices/echelonstride/echelonstride.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class echelonstride : public treadmill {
double forceInitSpeed = 0.0, double forceInitInclination = 0.0);
bool connected() override;
double minStepInclination() override;
void proxyVirtualTreadmillCommand(const QByteArray &value);

bool autoPauseWhenSpeedIsZero() override;
bool autoStartWhenSpeedIsGreaterThenZero() override;
Expand Down
8 changes: 6 additions & 2 deletions src/devices/fakerower/fakerower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ void fakerower::update() {
settings.value(QZSettings::bike_cadence_sensor, QZSettings::default_bike_cadence_sensor).toBool();
bool ios_peloton_workaround =
settings.value(QZSettings::ios_peloton_workaround, QZSettings::default_ios_peloton_workaround).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower) {
bool virtual_device_echelon =
settings.value(QZSettings::virtual_device_echelon, QZSettings::default_virtual_device_echelon).toBool();
if (ios_peloton_workaround && cadence && !virtual_device_rower && !virtual_device_echelon) {
qDebug() << "ios_peloton_workaround activated!";
h = new lockscreen();
h->virtualbike_ios();
Expand Down Expand Up @@ -123,7 +125,9 @@ void fakerower::update() {
settings.value(QZSettings::bike_cadence_sensor, QZSettings::default_bike_cadence_sensor).toBool();
bool ios_peloton_workaround =
settings.value(QZSettings::ios_peloton_workaround, QZSettings::default_ios_peloton_workaround).toBool();
if (ios_peloton_workaround && cadence && h && firstStateChanged) {
bool virtual_device_echelon =
settings.value(QZSettings::virtual_device_echelon, QZSettings::default_virtual_device_echelon).toBool();
if (ios_peloton_workaround && cadence && h && firstStateChanged && !virtual_device_echelon) {
h->virtualbike_setCadence(currentCrankRevolutions(), lastCrankEventTime());
h->virtualbike_setHeartRate((uint8_t)metrics_override_heartrate());
}
Expand Down
4 changes: 3 additions & 1 deletion src/devices/faketreadmill/faketreadmill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ void faketreadmill::update() {
settings.value(QZSettings::bike_cadence_sensor, QZSettings::default_bike_cadence_sensor).toBool();
bool ios_peloton_workaround =
settings.value(QZSettings::ios_peloton_workaround, QZSettings::default_ios_peloton_workaround).toBool();
if (ios_peloton_workaround && cadence && h && firstStateChanged) {
bool virtual_device_echelon =
settings.value(QZSettings::virtual_device_echelon, QZSettings::default_virtual_device_echelon).toBool();
if (ios_peloton_workaround && cadence && h && firstStateChanged && !virtual_device_echelon) {
h->virtualbike_setCadence(currentCrankRevolutions(), lastCrankEventTime());
h->virtualbike_setHeartRate((uint8_t)metrics_override_heartrate());
}
Expand Down
Loading
Loading