Repository navigation
DEV-976: stop turning the link CRC on for Shimmer3R firmware that drops it at a stop - #316
Merged
Merged
Conversation
…ps it at a stop Shimmer3R LogAndStream v0.00.002 to v1.00.010 turn the Bluetooth link CRC off by themselves whenever sensing stops (S4Sens_stopSensing, s4_sensing.c:354 at v1.00.010): after STOP_STREAMING, STOP_SDBT and STOP_LOGGING, and when the user button or docking ends SD logging. Nothing tells the host. The stop's own ACK still carries the CRC, but every reply after it is bare. The driver turned the default CRC on at every connect for these releases too (firmware code 8 from Shimmer3R LogAndStream 0.0.1), and kept expecting it after a stop, so default Consensys sessions lost sync after every stop. c8016de3 removed the clear, and v1.00.011 is the first release that keeps the CRC. isBtCrcModeSupported() is now false for those releases, through the new isBtCrcClearedWhenSensingStops(), so connecting leaves the CRC off and logs why. writeBtCommsCrcMode() refuses a CRC wherever isBtCrcModeSupported() is false, which also covers the enableBtComms*Crc() helpers; turning the CRC off is never refused where the command exists. Refusing, rather than dropping the expectation after a stop, also covers the stops the device makes on its own. The gate checks the hardware, because Shimmer3 and Shimmer3R LogAndStream versions overlap and no Shimmer3 release clears the CRC at a stop. It follows the reported hardware, so the v1.00.008 side build, which reports a Shimmer3, is let through, as in the web SDK (shimmer-web-sdk#178). API_00025 pins the boundary: Shimmer3R 1.0.10 refused, 1.0.11 allowed, Shimmer3 1.0.8 allowed, and OFF never refused. The simulator suites now assert the CRC mode after connecting: off for the simulated Shimmer3R (v0.0.1), the default for the Shimmer3. Not run against a real Shimmer3R on v1.00.010 or earlier. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 4, 2026
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 Java counterpart of the DEV-976 fix in ShimmerResearch/shimmer-web-sdk#178. That fix refuses
setCrcMode(1|2)on the same firmware and exportsSHIMMER3R_LINK_CRC_MIN_FIRMWARE= {1, 0, 11}.Defect
SET_CRC_COMMAND, 0x8B) off by themselves whenever sensing stops. The clear is inS4Sens_stopSensing(S3R_Production/S4_App/s4_sensing.c:354atLogAndStream_Shimmer3R_v1.00.010).isBtCrcModeSupported()was true, andinitializeShimmer3or3Rturned on the default CRC (1 byte) at every connect.mBtCommsCrcModeCurrent. After a stop, GET replies were still read with a CRC byte and stream packets were still sized with one.Fix
isBtCrcClearedWhenSensingStops(). It is true for Shimmer3R LogAndStream before 1.0.11, checked against the hardware, firmware ID and version withisThisVerCompatibleWith(HW_ID.SHIMMER_3R, FW_ID.LOGANDSTREAM, 1, 0, 11).isBtCrcModeSupported()is nowgetFirmwareVersionCode() >= 8 && !isBtCrcClearedWhenSensingStops(). The connect path already asks it, so connecting now leaves the CRC off. When a CRC default is set, it logs why.writeBtCommsCrcMode()refuses a CRC whereverisBtCrcModeSupported()is false. That coversenableBtCommsOneByteCrc()andenableBtCommsTwoByteCrc()too, which the Android example calls directly. Turning the CRC off is never refused where the command exists.SET_CRCat connect is safe. v1.00.010 clears the CRC at startup and on every disconnect (shimmer_bt_comms.c:1068and:2543), and the driver already assumes it is off on connect.Why the hardware is checked: Shimmer3 and Shimmer3R LogAndStream versions overlap (Shimmer3 has v1.00.003 to v1.01.005), and no Shimmer3 release clears the CRC at a stop. Shimmer3 v1.00.008 clears it only at protocol init and on disconnect.
One build reports the wrong hardware.
LogAndStream_Shimmer3R_v1.00.008is a side build for older Consensys (OLD_CONSENSYS_SUPPORT 1) that reports hardware 3. As in the web SDK, the gate follows the reported hardware and lets it through. Refusing every Shimmer3 on v1.0.8 would be wrong far more often.Testing
New
API_00025_Shimmer3rBtCrcGateTest(4 tests, in ShimmerDriverPC):isBtCrcModeSupported(),writeBtCommsCrcMode()and both enable helpers, and nothing is queued.Connect path: the simulator suites now check the CRC mode after connecting. It is off for the simulated Shimmer3R (LogAndStream v0.0.1) and 1 byte for the simulated Shimmer3 (v0.16.0).
Proof the tests catch the bug (unpatched driver):
shimmer3rBeforeV1_00_011IsRefusedfails on "Shimmer3R LogAndStream v1.0.10", and the Shimmer3R simulator check fails withexpected:<OFF> but was:<ONE_BYTE_CRC>.Simulator log, before and after: the 8 simulated Shimmer3R connects sent
SET_CRC_COMMAND [0x8B 0x01]8 times before and 0 times after. The Shimmer3 suites still send it.Full suites:
cd ShimmerDriver && ./gradlew testcd ShimmerDriverPC && ./gradlew build -iAn unrelated flake, seen once:
API_0000X_ByteCommunicationShimmer3.test002(a Shimmer3, so outside this change) failed in one full run. Its connect stalled after initialisation, inside the progress-callback delivery, with nothing transmitted. It then passed 5 of 5 reruns with this change and 5 of 5 without. The simulator suites never disconnect their devices, so earlier tests' devices keep running and their traffic shows up in later suites' logs. That is worth a separate look.Not verified on hardware
No Shimmer3R on v1.00.010 or earlier has been run against this. The fix rests on the firmware source and the simulator. To check on one: connect with Consensys at its default CRC mode, start and stop streaming, and confirm the next command is answered.
After merge: consumers
None of these picks this up on its own:
shimmerdriverandshimmerbluetoothmanagerat 0.11.7_beta (ShimmerAndroidInstrumentDriver/build.gradle). It needs ashimmerdriverrelease containing this, and the pin bumped.libs/ShimmerJavaClass.jar, the ShimmerDriverPC shadow jar built 2025-11-24, which still has the old gate. The jar needs rebuilding and re-vendoring.Siblings (CLAUDE.md §4)
Shimmer3Protocol.connect()turns on a 2-byte CRC at every connect, before reading any version, and never drops it after a stop. It supports the Shimmer3R over BLE. Not changed here.ShimmerLogAndStream(..., BTCRCMode CRCmode)writes the requested CRC at connect wheneverIsCRCSupported()is true, and that is true for every Shimmer3R LogAndStream.BluetoothCRCModeis reset only onConnect(). The default is off.SET_CRC.🤖 Generated with Claude Code