diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fa89a9e..bb70f85c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed DNS server in AP mode. - Fixed an issue with IC4 and variants not displaying device name in Bluetooth scanner. Fixes #500 - Switched from using Power Table to a Torque Table for better compensation in cad variations. -- added test for invalid Peloton data to keep stepper from running away without resistance information. +- added test for invalid Peloton data to keep stepper from running away without resistance information. +- Fixed a bug with Trainer Day and rapid ERG sending. ### Hardware - Wire diameter reduced from 7.2mm to 6.0mm on the window passthrough to accommodate the latest batch of cables. diff --git a/src/BLE_Server.cpp b/src/BLE_Server.cpp index 644d361b..f786cdc5 100644 --- a/src/BLE_Server.cpp +++ b/src/BLE_Server.cpp @@ -385,7 +385,7 @@ void processFTMSWrite() { uint8_t returnValue[3] = {FitnessMachineControlPointProcedure::ResponseCode, (uint8_t)rxValue[0], FitnessMachineControlPointResultCode::OpCodeNotSupported}; ftmsStatus = {FitnessMachineStatus::ReservedForFutureUse}; - rtConfig.setFTMSMode((uint8_t)rxValue[0]); + switch ((uint8_t)rxValue[0]) { case FitnessMachineControlPointProcedure::RequestControl: @@ -408,6 +408,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetInclination: { + rtConfig.setFTMSMode((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; pCharacteristic->setValue(returnValue, 3); @@ -415,7 +416,6 @@ void processFTMSWrite() { port *= 10; rtConfig.setTargetIncline(port); - logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Incline Mode: %2f", rtConfig.getTargetIncline() / 100); ftmsStatus = {FitnessMachineStatus::TargetInclineChanged, (uint8_t)rxValue[1], (uint8_t)rxValue[2]}; @@ -424,6 +424,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetResistanceLevel: { + rtConfig.setFTMSMode((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; ftmsTrainingStatus[1] = FitnessMachineTrainingStatus::Other; // 0x00; fitnessMachineTrainingStatus->setValue(ftmsTrainingStatus, 2); @@ -447,6 +448,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetPower: { + rtConfig.setFTMSMode((uint8_t)rxValue[0]); if (spinBLEClient.connectedPM || rtConfig.watts.getSimulate()) { returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; @@ -455,7 +457,7 @@ void processFTMSWrite() { rtConfig.watts.getValue(), rtConfig.getTargetIncline() / 100); ftmsStatus = {FitnessMachineStatus::TargetPowerChanged, (uint8_t)rxValue[1], (uint8_t)rxValue[2]}; - ftmsTrainingStatus[1] = FitnessMachineTrainingStatus::Other; // 0x0C; + ftmsTrainingStatus[1] = FitnessMachineTrainingStatus::WattControl; // 0x0C; fitnessMachineTrainingStatus->setValue(ftmsTrainingStatus, 2); // Adjust set point for powerCorrectionFactor and send to FTMS server (if connected) int adjustedTarget = rtConfig.watts.getTarget() / userConfig.getPowerCorrectionFactor(); @@ -492,6 +494,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetIndoorBikeSimulationParameters: { // sim mode + rtConfig.setFTMSMode((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; pCharacteristic->setValue(returnValue, 3); @@ -519,6 +522,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SpinDownControl: { + rtConfig.setFTMSMode((uint8_t)rxValue[0]); uint8_t controlPoint[6] = {FitnessMachineControlPointProcedure::ResponseCode, 0x01, 0x24, 0x03, 0x96, 0x0e}; // send low and high speed targets pCharacteristic->setValue(controlPoint, 6); logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Spin Down Requested"); @@ -530,6 +534,7 @@ void processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetedCadence: { + rtConfig.setFTMSMode((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; pCharacteristic->setValue(returnValue, 3); diff --git a/src/ERG_Mode.cpp b/src/ERG_Mode.cpp index b3ebc6e6..4767fd6e 100644 --- a/src/ERG_Mode.cpp +++ b/src/ERG_Mode.cpp @@ -567,7 +567,7 @@ void ErgMode::computeErg() { } // SetPoint changed - if (this->setPoint != newWatts.getTarget()) { + if (abs(this->setPoint - newWatts.getTarget() > 20)) { _setPointChangeState(newCadence, newWatts); return; }