Skip to content

DEV-1108: BMP581 pressure sensor support on the Shimmer3R - #20

Merged
JongChern merged 1 commit into
mainfrom
DEV-1108_bmp581_support
Oct 15, 2026
Merged

JongChern merged 1 commit into
mainfrom
DEV-1108_bmp581_support

Conversation

@marknolan

Copy link
Copy Markdown
Member

Adds BMP581 support for the Shimmer3R, which replaces the BMP390 on up-rev'd boards (DEV-817/818). Jira: DEV-1108.

Problem

The 0xA7 handler dropped the reply's length and sensor-ID bytes and always parsed 21 BMP390 coefficients. A BMP581 replies [A6][01][03] (sensor ID 3, no coefficients) from LogAndStream_Shimmer3R v1.01.007. It also read receivedBytes[1] before checking the count.

Change

  • Decode [len][sensorId][n bytes], and reject a length that doesn't match the ID (22/24/21/0 bytes for IDs 0/1/2/3). The sensor type is stored on PressureTempSensor.
    • ID 2 still parses through the unchanged BMP390 path.
    • ID 3 parses nothing.
  • Fallback when 0xA7 gives no usable reply: the firmware's SR-number rule (ShimBrd_isBmp581PresentPerSrNumber, including SR38 >= 4.2 and both SR48 ranges) plus LogAndStream >= 1.1.6.
  • BMP581 conversion (see the sketch below): no clamp, and channel names and units are unchanged.
  • Oversampling is read as 3 bits (the MSB is ConfigSetupByte4 bit 0), and the 8 BMP581 labels are exposed.
Pa = u24 / 64           (reported in kPa, as for the BMP390)
degC = signExtend24(u24) / 65536   (signed, masked first; see DEV-1102)

Tests

XCTests in SensorTest.swift:

  • the conversion vectors shared with the Java, Web SDK, C# and pyshimmer implementations, including raw T 0xFE5556 → −1.6667 °C, the DEV-1102 regression
  • the frame vector
  • 0xA6 decoding
  • all the firmware test_bmp581_gate cases

This has not been compiled locally (no Xcode on the authoring machine). This PR's CI run is the first build.

Known limitations

Cross-API check

The same work is under way in C# (DEV-1107), pyshimmer (DEV-1109), Java (DEV-1110: in-band ID and SR38) and the Web SDK SD log (DEV-1111).

🤖 Generated with Claude Code

The 0xA6 reply to 0xA7 is [len = 1 + n][sensorId][n coefficient
bytes]. The handler dropped len and sensorId and parsed 21 BMP390
coefficients from whatever followed, which on a BMP581 (id 3, n = 0)
is a 1-byte payload. It also indexed receivedBytes[1] before checking
the count, and did not wait for the whole reply.

- Wait for the full reply, decode len and sensorId, and reject a len
  that does not match the id (22/24/21/0 for ids 0/1/2/3). The sensor
  type is stored on PressureTempSensor. Id 2 parses the coefficients
  through the unchanged BMP390 path; id 3 parses none.
- When 0xA7 fails or the reply is malformed, fall back to the
  firmware's SR-number rule (ShimBrd_isBmp581PresentPerSrNumber, incl.
  SR38 >= 4.2 and the two SR48 windows) plus LogAndStream >= 1.1.6.
  A NACK (v1.01.006 on a BMP581) only reaches the fallback once NACK
  handling resumes the command with a failure.
- processData: BMP581 branch, Pa = u24 / 64 (reported in kPa as for
  the BMP390) and degC = signExtend24(u24) / 65536, masked first, no
  clamp. Channel names and formats are unchanged.
- setInfoMom reads the oversampling MSB from ConfigSetupByte4 bit 0
  (InfoMem 130) on the Shimmer3R; the 8 BMP581 labels are exposed.
  InfoMem writes on the Shimmer3R are still not implemented.
- XCTests: shared conversion vectors, the frame vector, 0xA6 decoding
  and the firmware's SR-rule cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@JongChern JongChern left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the Java driver's master. The BMP581 conversion, the SR-number rule (including SR38-4-2 and both SR48 ranges) with its LogAndStream v1.01.006 guard, parsing the 0xA6 reply by its declared length, the in-band sensor ID overriding the rule, and the 3-bit resolution field all match.

Also checked:

  • The firmware version and expansion board are read before the pressure request, so the fallback has what it needs.
  • CI builds and runs the tests (32 pass, including the BMP581 ones). This covers the build the description says wasn't done locally.

Still open before release: a hardware check on a BMP581 Shimmer3R.

@JongChern
JongChern merged commit a23c0be into main Oct 15, 2026
1 check passed
@JongChern
JongChern deleted the DEV-1108_bmp581_support branch October 15, 2026 02:15
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.

2 participants