Skip to content

DEV-971: #343 review fixes - leave byte 233 out before a read, one NACK handler, renumber tests - #351

Merged
JongChern merged 1 commit into
DEV-971_event_channelfrom
DEV-971_343_review
Nov 13, 2026
Merged

JongChern merged 1 commit into
DEV-971_event_channelfrom
DEV-971_343_review

Conversation

@JongChern

@JongChern JongChern commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

DEV-971. Fixes for three points from the review comment on #343, into #343's branch, as #349 did for #348. The one defect, byte 233, was first reproduced by tests that failed on the unchanged code.

Review point Before Fix
Bytes 232 and 233 are treated differently before a read A Bluetooth configuration write before any read left byte 232 out, but sent a Shimmer3R's byte 233 (DEV-99 audio mode and gain, DEV-1413 sound level) as 0. That turned the unit's audio mode and sound level off. 3 of the 5 tests in the new API_00047_AudioConfigWriteTest failed Byte 233 is left out too, until it has been read or the sound level is turned on. The chunk at 128 goes as [128..231] [234..255]
The NACK handler is duplicated processEventChannelProbeNack() repeated processNackFromCommand()'s unwinding, and only the not-streaming ACK path took it processNackFromCommand() handles the probe: it marks the event channel unsupported and does not call eventCommandRefused(). The duplicate is gone
Duplicate test numbers API_00036_ButtonLogModeTest and API_00037_ButtonLogModeConfigWriteTest shared their numbers with master's API_00036_LogStartRefusedTest and API_00037_StreamingLogStartRefusedTest Renamed API_00045 and API_00046

Byte 233

  • When it is written. SensorSoundLevel.isAudioConfigKnown() is true once byte 233 has been parsed, or while the sound level is on. ShimmerObject.isAudioConfigKnown() asks it, and is true on hardware without the byte. With the sound level turned on before a read, the byte is still written with bits 0-3 at 0: the host never sets them, and one bit cannot be written on its own.
  • Which firmware. The same firmware that byte 232 is left out on, from isSupportedSetFeature() (Shimmer3R v1.00.052, Shimmer3 v1.00.017). On Shimmer3R firmware before that, the write still goes in whole chunks, as API_00046 requires, so byte 233 is still written there. This is unchanged from master.
  • The write. writeMem()'s private overload takes a list of bytes to leave out instead of one. With none, it sends exactly the chunks it did before.
  • It is master's behaviour, from DEV-1413, not a regression in DEV-971: keep configuration byte 232 on a full write, expose its fields, probe for the event channel #343. It is fixed here because DEV-971: keep configuration byte 232 on a full write, expose its fields, probe for the event channel #343 adds the mechanism for leaving bytes out.
  • Other host APIs: none need it.
    • The web SDK writes over the bytes it read.
    • shimmer-host-core writes the configuration only after its handshake has read it.
    • C# and Swift write the caller's image unchanged, and pyshimmer writes no configuration.

Tests

Suite Result
API_00047_AudioConfigWriteTest (new) 5/5. 3 failed on the unchanged code: byte 233 sent before a read, both on its own and with byte 232 set. The other 2 cover behaviour that stays: the byte given back once read, and the sound level turned on before a read
API_00046_ButtonLogModeConfigWriteTest 14/14. On a Shimmer3R, the chunks before a read now leave out 233 as well as 232
API_00038_EventChannelProbeTest 6/6. New: the probe's NACK is not reported as a refused command. It passed before the merge as well, as a guard on it
ShimmerDriver test 219/219
ShimmerDriverPC (clean build, as CI runs it) 161/161
Java 8 MATLAB jar (shadowJar -PmatlabJava8) Builds
ShimmerPCBasicExamples Compiles

CI does not run on this base.

On a unit

On a Shimmer3R running LogAndStream v1.1.25 over Bluetooth Classic, at d7d7fd80:

  • A configuration written before the read (comment): the chunk at 128 went out as [128, 104] and [234, 22], and the firmware ACKed both pieces. The unit kept its own bytes 232 and 233. Both pieces were stored, and the MAC came back as the unit's own.
  • The probe on released firmware (comment): the probe was NACKed on connect and again when asked later. isEventChannelSupported() was false, the opt-in and the status read were refused without being sent, the link stayed up, and a stream ran normally afterwards.

Not run on a unit: firmware with the event channel (v1.1.26), and a Shimmer3.

Still open from the review

🤖 Generated with Claude Code

… tests

From the review of #343:

- A Bluetooth configuration write before any read sent a Shimmer3R's
  byte 233 (DEV-99 audio mode and gain, DEV-1413 sound level) as 0, which
  turned the unit's audio mode off. It is now left out as byte 232 is,
  unless it was read or the sound level is turned on, on the same
  firmware. writeMem() takes a list of bytes to leave out. 3 of the 5
  tests in API_00047_AudioConfigWriteTest fail without it.
- The event channel probe's NACK now goes through processNackFromCommand(),
  which marks the event channel unsupported and does not report the NACK
  as a refused command. processEventChannelProbeNack() is gone.
- API_00036_ButtonLogModeTest and API_00037_ButtonLogModeConfigWriteTest
  are now API_00045 and API_00046: master's log-start-refused tests have
  those numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern

Copy link
Copy Markdown
Contributor Author

Bench, 13 Nov 2026: the event channel probe on released firmware that NACKs it.

A Shimmer3R on LogAndStream v1.1.25, the release without the event channel, over Bluetooth Classic with the 1-byte link CRC the driver sets at connect. Code: d7d7fd80 (#351). A headless check: connect, read what the driver learnt, ask again, then stream for 5 s. Nothing in the unit's configuration, clock or logging was written.

Check Result
Connect, with the probe in the sequence Finished in 6.8 s, link kept
The probe on connect NACKed. isEventChannelSupported() false, logged as NACK Received for Command: [0xB7] SET_FEATURE_COMMAND, no event channel
writeEventStream(true) Refused, nothing sent
readEventChannelStatus() Refused, nothing sent
The probe asked again while idle NACKed again: still false, link kept
A stream after the NACKs Started; 245 packets in 5 s at 51.2 Hz; stopped, back to Ready
Link Never lost; no ACK timeouts
Byte 232 Read as 0x00 (legacy), a value the firmware keeps
Byte 233 Read; audio mode and gain 0

The same check just before, with the unit still on v1.1.26: the probe ACKed, connect took 4.1 s, and a 5 s stream gave 247 packets with the link kept.

Not covered:

  • A Shimmer3 on firmware with SET_FEATURE (v1.00.017 or later).
  • The configuration write before a read, which leaves bytes 232 and 233 out. This run did not write a configuration.

🤖 Generated with Claude Code

@JongChern

Copy link
Copy Markdown
Contributor Author

Bench, 13 Nov 2026: a configuration written on connect, before the read.

A Shimmer3R on LogAndStream v1.1.25 over Bluetooth Classic, with the 1-byte link CRC. Code: d7d7fd80 (#351). The configure-on-connect path (setSetupDeviceWhileConnecting(true)) queues writeConfigBytes(false) ahead of the configuration read. So the driver writes its image, named BENCH351, without having read bytes 232 and 233, and leaves them out.

The run:

  1. Read the unit's configuration and save it.
  2. Write it back with bytes 232 and 233 set to 0x04, and the unused bytes 234 and 255 set to 0x5A, so the write would show over them.
  3. Reconnect with configure-on-connect.
  4. Write the saved configuration back.
Check Result
SET_INFOMEM sent [0, 128] [128, 104] [234, 22] [256, 128] [384, 128]: the chunk at 128 in two pieces, 232 and 233 in neither
Firmware's answer Every piece ACKed: no NACK, no timeout, link kept
Bytes 232 and 233 Still 0x04: the unit kept its own
Piece [128..231] Landed: the name reads back as BENCH351. The MAC (224-229, written as 0xFF) reads back as the unit's own, so the firmware's handling of the chunk at 128 still applies when it is 104 bytes long
Piece [234..255] Landed: bytes 234 and 255 went from 0x5A to the 0x00 written
Every other byte Read back as written
Saved configuration written back Read back as saved, except byte 230, the SD file write flags (0x00 to 0x01), which the firmware sets after a write and later clears. The next run's first read matched the original byte for byte

Run three times. The first attempt never reached the write: COM32 was still busy 3 s after the previous disconnect. The second and third passed; the third added the 0x5A check.

Not covered:

🤖 Generated with Claude Code

@JongChern
JongChern marked this pull request as ready for review November 13, 2026 08:51
@JongChern
JongChern merged commit a7dde8d into DEV-971_event_channel Nov 13, 2026
JongChern added a commit that referenced this pull request Nov 13, 2026
Brings in #343 as merged, with #351's event channel fixes and renumbered tests.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant