@@ -356,7 +356,6 @@ void ftmsbike::forceResistance(resistance_t requestResistance) {
356356 uint8_t write[] = {FTMS_SET_TARGET_RESISTANCE_LEVEL , 0x00 };
357357 if (_3G_Cardio_RB || SL010 )
358358 requestResistance = requestResistance * 10 ;
359- requestResistance = (resistance_t )qRound (((double )requestResistance) * bikeResistanceGain);
360359 write[1 ] = ((uint8_t )(requestResistance));
361360 writeCharacteristic (write, sizeof (write),
362361 QStringLiteral (" forceResistance " ) + QString::number (requestResistance));
@@ -1889,6 +1888,21 @@ void ftmsbike::ftmsCharacteristicChanged(const QLowEnergyCharacteristic &charact
18891888 b[1 ] = powerRequested & 0xFF ;
18901889 b[2 ] = powerRequested >> 8 ;
18911890 }
1891+ } else if (b.at (0 ) == FTMS_SET_TARGET_RESISTANCE_LEVEL && bikeResistanceGain != 1.0 ) {
1892+ if (b.length () == 2 ) {
1893+ uint8_t resistance = (uint8_t )b.at (1 );
1894+ qDebug () << " applying bikeResistanceGain to FTMS_SET_TARGET_RESISTANCE_LEVEL (1-byte) from" << resistance;
1895+ resistance = (uint8_t )qRound (((double )resistance) * bikeResistanceGain);
1896+ qDebug () << " to" << resistance;
1897+ b[1 ] = resistance;
1898+ } else if (b.length () >= 3 ) {
1899+ uint16_t resistance = (((uint8_t )b.at (1 )) + ((uint8_t )b.at (2 ) << 8 ));
1900+ qDebug () << " applying bikeResistanceGain to FTMS_SET_TARGET_RESISTANCE_LEVEL (2-byte) from" << resistance;
1901+ resistance = (uint16_t )qRound (((double )resistance) * bikeResistanceGain);
1902+ qDebug () << " to" << resistance;
1903+ b[1 ] = resistance & 0xFF ;
1904+ b[2 ] = resistance >> 8 ;
1905+ }
18921906 }
18931907 // gears on erg mode is quite useless and it's confusing
18941908 /* else if(b.at(0) == FTMS_SET_TARGET_POWER && b.length() > 2) {
0 commit comments