@@ -1477,6 +1477,29 @@ void ftmsbike::ftmsCharacteristicChanged(const QLowEnergyCharacteristic &charact
14771477 if (gattWriteCharControlPointId.isValid ()) {
14781478 qDebug () << " routing FTMS packet to the bike from virtualbike" << characteristic.uuid () << newValue.toHex (' ' );
14791479
1480+ // D500V2 workaround: track request control (0x00) and start simulation (0x07) commands
1481+ // If we receive simulation params (0x11) without start simulation, inject it first
1482+ if (D500V2 && b.length () > 0 ) {
1483+ uint8_t commandCode = (uint8_t )b.at (0 );
1484+
1485+ if (commandCode == FTMS_REQUEST_CONTROL ) {
1486+ // Command 0x00: Request Control - expect start simulation next
1487+ awaiting_start_simulation_after_request_control = true ;
1488+ qDebug () << " D500V2 workaround: received REQUEST_CONTROL (0x00), now awaiting START_RESUME (0x07)" ;
1489+ } else if (commandCode == FTMS_START_RESUME ) {
1490+ // Command 0x07: Start Resume - no longer awaiting
1491+ awaiting_start_simulation_after_request_control = false ;
1492+ qDebug () << " D500V2 workaround: received START_RESUME (0x07), ready for simulation params" ;
1493+ } else if (commandCode == FTMS_SET_INDOOR_BIKE_SIMULATION_PARAMS && D500V2 && awaiting_start_simulation_after_request_control) {
1494+ // Command 0x11: Set Simulation Params - but we're still awaiting start simulation
1495+ // For D500V2, inject the start simulation command (0x07) first
1496+ qDebug () << " D500V2 workaround: received SET_INDOOR_BIKE_SIMULATION_PARAMS (0x11) without START_RESUME, injecting 0x07 first" ;
1497+ uint8_t startSimulation[] = {FTMS_START_RESUME };
1498+ writeCharacteristic (startSimulation, sizeof (startSimulation), " injectWrite [D500V2 workaround: start simulation 0x07]" , false , true );
1499+ awaiting_start_simulation_after_request_control = false ;
1500+ }
1501+ }
1502+
14801503 // handling gears
14811504 if (b.at (0 ) == FTMS_SET_INDOOR_BIKE_SIMULATION_PARAMS && (zwiftPlayService == nullptr || !gears_zwift_ratio)) {
14821505 double min_inclination = settings.value (QZSettings::min_inclination, QZSettings::default_min_inclination).toDouble ();
@@ -1684,6 +1707,9 @@ void ftmsbike::deviceDiscovered(const QBluetoothDeviceInfo &device) {
16841707 ergModeSupported = false ;
16851708 max_resistance = 32 ;
16861709 DOMYOS = true ;
1710+ } else if (bluetoothDevice.name ().toUpper ().startsWith (" D500V2" )) {
1711+ qDebug () << QStringLiteral (" D500V2 found - enabling workaround for start simulation command" );
1712+ D500V2 = true ;
16871713 } else if ((bluetoothDevice.name ().toUpper ().startsWith (" 3G Cardio RB" ))) {
16881714 qDebug () << QStringLiteral (" _3G_Cardio_RB found" );
16891715 _3G_Cardio_RB = true ;
0 commit comments