Repository navigation
Conversation
The Shimmer3R firmware adds channel 0x38, SOUND_LEVEL: the A-weighted level at the microphone as an int16, little-endian, in 0.01 dB(A). -32768 means no level. interpretDataPacketFormat already sized unknown IDs at two bytes, so packets stayed aligned, but the level was dropped. - SoundLevelSensor decodes it: RAW, and Calibrated in dB(A) (raw / 100, NaN for -32768) while calibration is on. SoundLevelSensor.calibrate() is public. - Shimmer3Protocol enables it when a Shimmer3R's inquiry lists 0x38 (it has no enabled-sensors bit), turns it off in disableSensors whatever the hardware, and runs it in buildMsg before the battery. - Sensor.SensorUnits.decibelsA, ChannelContentsShimmer3.SoundLevel. - SoundLevelSensor.swift has its four project.pbxproj entries. SensorTest covers the calibration, the decode at its index with and without calibration, and four real packets from a Shimmer3R around its first level. The wiring inside Shimmer3Protocol has no test: the class needs a live CBPeripheral. Written without Xcode, so CI is the first compile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…evel Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What
The Shimmer3R firmware in ShimmerResearch/log-and-stream-common#230 and ShimmerResearch/shimmer3r-firmware#324 adds channel
0x38,SOUND_LEVEL. It carries the A-weighted level at the microphone as an int16, little-endian, in 0.01 dB(A), and-32768means no level. The format is in log-and-stream-common'sSHIMMER3_STREAMING_DATA_FORMAT.md§5.7. That firmware is merged, and LogAndStream_Shimmer3R v1.01.026 will be the first release with the channel. The doc comment names it.interpretDataPacketFormatalready sized unknown IDs at two bytes, so packets stayed aligned, but the level was dropped.SoundLevelSensor(new) decodes it. It always addsSound LevelRaw, and adds Calibrated indB(A)while calibration is on: raw / 100, or NaN for-32768.SoundLevelSensor.calibrate(raw:)andNO_LEVELare public.Shimmer3Protocol:interpretDataPacketFormatenables it and sets its index when a Shimmer3R's inquiry lists0x38. The channel has no enabled-sensors bit; the firmware turns it on from configuration byte 233 bit 4.disableSensorsturns it off, whatever the hardware.buildMsgruns it before the battery.Sensor.SensorUnits.decibelsAandChannelContentsShimmer3.SoundLevel.project.pbxproj:SoundLevelSensor.swifthas all four entries.Tested
CI was the first compile. It was written without Xcode. This PR's first CI run built it and ran the suite:
** TEST SUCCEEDED **, with the three new cases passing.SensorTestadds three cases:-32768;The firmware's own test rig decoded the same levels from the same bytes.
Not covered by a test: the wiring inside
Shimmer3Protocol, because that class needs a liveCBPeripheral(AGENTS.md). The packet indexes the test uses are the onesinterpretDataPacketFormatcomputes for those channel lists, worked out by hand.The full captures (122,482 stream packets and a 30,719-record SD file) decode exactly in the C# port (DEV-1413: decode the Shimmer3R sound level channel (0x38) Shimmer-C-API#232) and the web SDK (DEV-1413: Shimmer3R sound-level channel 0x38 and byte 233 bit 4 (0.5.13) shimmer-web-sdk#230). This API has no way to replay them without a radio.
Not done
Seen in passing, not changed
There are two problems with the battery, both older than this change, and they belong in their own fix:
BattVoltageSensor.processDataalways reads bytes 3-4, the first channel after the timestamp, not the battery's own packet index.initializeSensorsnorinterpretDataPacketFormatturns it on.🤖 Generated with Claude Code