Skip to content

Commit a7e8fd6

Browse files
author
root
committed
fix: keep FTMS queue blocked until exact response
1 parent 46afa1b commit a7e8fd6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/devices/ftmsbike/ftmsbike.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ ftmsbike::ftmsbike(bool noWriteResistance, bool noHeartService, int8_t bikeResis
6262
writeTimeoutTimer = new QTimer(this);
6363
writeTimeoutTimer->setSingleShot(true);
6464
connect(writeTimeoutTimer, &QTimer::timeout, this, [this]() {
65+
if (currentWriteWaitingForResponse && !currentWriteExpectedResponse.isEmpty()) {
66+
qDebug() << QStringLiteral("writeCharacteristic timeout - still waiting for exact FTMS response")
67+
<< currentWriteExpectedResponse.toHex(' ');
68+
writeTimeoutTimer->start(2000);
69+
return;
70+
}
6571
qDebug() << QStringLiteral("writeCharacteristic timeout - processing next in queue");
6672
completeCurrentWrite();
6773
});
@@ -193,14 +199,14 @@ void ftmsbike::init() {
193199
uint8_t write[] = {FTMS_REQUEST_CONTROL};
194200
bool ret = writeCharacteristic(write, sizeof(write), "requestControl", false, true);
195201

196-
// Dirty Tacx Flux 2 test: the native app requests control, pauses, requests
202+
// Dirty Tacx Flux 2 test: the native app requests control, resets, requests
197203
// control again, and only then starts/resumes the simulation. Each command
198204
// is queued with response waiting enabled so the next command is not sent
199-
// until the previous FTMS response has been received (or timed out).
205+
// until the previous FTMS response has been received.
200206
const bool tacx_flux_2 = bluetoothDevice.name().compare(QStringLiteral("Tacx Flux-2 33326"), Qt::CaseInsensitive) == 0;
201207
if (tacx_flux_2) {
202-
uint8_t pause[] = {FTMS_STOP_PAUSE};
203-
ret = writeCharacteristic(pause, sizeof(pause), "tacx flux 2 pause", false, true);
208+
uint8_t reset[] = {FTMS_RESET};
209+
ret = writeCharacteristic(reset, sizeof(reset), "tacx flux 2 reset", false, true);
204210
ret = writeCharacteristic(write, sizeof(write), "tacx flux 2 requestControl", false, true);
205211
}
206212

0 commit comments

Comments
 (0)