fix: wahoo setSimGrade sent before setSimMode (KICKR CORE race condition) - #4814
Open
cagnulein wants to merge 1 commit into
Open
fix: wahoo setSimGrade sent before setSimMode (KICKR CORE race condition)#4814cagnulein wants to merge 1 commit into
cagnulein wants to merge 1 commit into
Conversation
…tor subscriptions On KICKR CORE, stateChanged subscribed to all 17 notifiable/indicatable characteristics across all services. The descriptorWritten callbacks trickle in slowly, so notificationSubscribed never reached zero before Zwift sent its first indoor-bike-simulation-parameters write. That write triggered inclinationChanged -> setSimGrade directly, bypassing the initRequest guard and the setSimMode that must precede it. Fix: subscribe only to CyclingPowerMeasurement (at most 1 descriptor write needed), so the init sequence fires almost immediately after service discovery. Add a fallback to fire init directly from stateChanged if no subscription was established at all. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On KICKR CORE (and similar Wahoo devices),
setSimGradewas being sent to the trainer beforesetSimModehad ever been sent.Root cause
stateChanged()subscribes to all notifiable/indicatable characteristics across all BLE services. On a KICKR CORE this amounts to 17 descriptor writes (notificationSubscribed = 17). ThedescriptorWrittencallbacks arrive slowly from the BLE stack — in the reported log only 9 of the 17 had arrived by the time Zwift sent its firstindoor bike simulation parametersFTMS command (~30 seconds after connection).Since
notificationSubscribednever reached 0,initRequestwas never set totrue, so theupdate()init block (which sendsunlock→setSimMode→setWheelCircumference) never ran.Meanwhile Zwift's FTMS write flows through a direct signal/slot path:
CharacteristicWriteProcessor2AD9 → changeSlope → inclinationChanged → setSimGrade…which bypasses
initRequestentirely, sendingsetSimGradeto a trainer that had never receivedsetSimMode.Fix
Subscribe only to
CyclingPowerMeasurementduringstateChanged()— at most 1 descriptor write — sodescriptorWrittenfires almost immediately and the init sequence (includingsetSimMode) completes before Zwift can send the first slope command.A fallback is also added: if no
CyclingPowerMeasurementsubscription was established at all,initRequestis set directly fromstateChanged()so the init always runs.This is a minimal, targeted fix. A previous attempt (PR #4530, closed as wontfix) addressed the same issue with additional unrelated changes; this PR contains only the essential change.
Test plan
setSimModeappears in the log before the firstsetSimGrade🤖 Generated with Claude Code