Repository navigation
DEV-1275: Report a Shimmer ready only once its connect sequence has ended - #333
Merged
Merged
Conversation
The connect sequence reads the unit's status part way through. On that reply, ShimmerPC.eventLogAndStreamStatusChanged() moved the state from CONNECTING to CONNECTED, and ShimmerDeviceCallbackAdapter marks every CONNECTED as initialised. So an app waiting for CONNECTED and initialised was told the unit was ready while the battery read, the calibration dump and the inquiry were still queued. Whatever the app did next went out in among that sequence: - streaming started part way through it, and a reply from the connect sequence landed in the stream, which then went silent; - a configure cut the calibration dump short, which left a Shimmer3's calibrated accel NaN in every sample (7 of 9 runs on the HIL). The sequence's own end, inquiryDone() and then isReadyForStreaming(), already moves CONNECTING to CONNECTED and sends NOTIFICATION_SHIMMER_FULLY_INITIALIZED. A status reply now leaves CONNECTING to it. The Shimmer3R simulator answered INQUIRY with the Shimmer3's 8-byte settings, which never parse as a Shimmer3R's 11. Its tests had only ever passed on the early CONNECTED, before the inquiry timed out. It now answers with settings that match its own InfoMem. API_00031 connects to the Shimmer3 simulator, whose sequence reads the status before the inquiry. It checks that CONNECTED comes only after the sequence's end, with nothing but the RTC write still queued. It fails without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Combined hardware verification. This used the Java HIL from #331 on a local merge of #331, #332, #333 and #334. The units were a Shimmer3 (LogAndStream v1.1.7) and a Shimmer3R (v1.1.21) over Bluetooth Classic, with nothing else on the bench.
|
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.
The bug
The connect sequence reads the unit's status part way through. Battery, BT firmware version, the calibration dump and the inquiry are still to come at that point.
On that status reply,
ShimmerPC.eventLogAndStreamStatusChanged()moved the state from CONNECTING to CONNECTED.ShimmerDeviceCallbackAdaptermarks every CONNECTED as initialised. So an app waiting for CONNECTED and initialised was told the unit was ready while the rest of the sequence was still queued.Whatever the app did next went out in among that sequence. The Java HIL (#331) hit two symptoms on real units:
The fix
The sequence's own end already moves CONNECTING to CONNECTED and sends
NOTIFICATION_SHIMMER_FULLY_INITIALIZED. That isinquiryDone(), thenisReadyForStreaming(). A status reply now leaves CONNECTING to it. One condition inShimmerPC.eventLogAndStreamStatusChanged():At CONNECTED, every read of the unit's configuration has been answered. The only thing that can still be queued is the RTC write that the status reply queues when the unit's clock isn't set. It runs before anything the app queues.
Behaviour change
CONNECTED now arrives a few hundred ms later than before: after the inquiry, not after the status read.
A connect whose inquiry reply never arrives now stays CONNECTING. Before, the status reply made it look ready, even though its packet format was never read.
Tests
API_00031_ConnectReadyAfterConnectSequenceTest(new) connects to the Shimmer3 simulator, whose sequence reads the status before the inquiry. It checks that CONNECTED comes only afterisReadyForStreaming(), with no read of the connect sequence still queued. It fails without the fix.ByteCommunicationSimulatorS3Rnow answers INQUIRY with a Shimmer3R's 11 bytes of settings. It inherited the Shimmer3's 8, which a Shimmer3R never parses, so the inquiry always timed out. Its 8 tests had only passed on the early CONNECTED, and they all failed with the fix until the simulator was corrected. The settings match the simulator's InfoMem.ShimmerDriverPC: 67 of 67 pass.On hardware
These runs used the Java HIL from #331, not yet merged, built locally together with this fix and the DEV-1291 fix (#332). The units were a Shimmer3 (RN4678, LogAndStream v1.1.7) and a Shimmer3R (v1.1.21), over Classic, with nothing else on the bench.
streamRest: calibration dump read before the configurestreamRestfailed on NaNOther APIs
Shimmer.javasets CONNECTED unconditionally on a status reply, in itslogAndStreamStatusChanged(). It overrides this method, so this fix won't reach it. The port is a separate PR in ShimmerAndroidAPI.🤖 Generated with Claude Code