Skip to content

DEV-1108: decide the Shimmer3R pressure sensor as the Java driver does - #26

Merged
JongChern merged 1 commit into
mainfrom
DEV-1108_follow_java_pressure_sensor_id
Nov 5, 2026
Merged

JongChern merged 1 commit into
mainfrom
DEV-1108_follow_java_pressure_sensor_id

Conversation

@JongChern

Copy link
Copy Markdown
Contributor

Follow-up to #20 (DEV-1108). It makes three small changes so the Swift API decides a Shimmer3R's pressure sensor the way the Java driver does.

Changes

  • No 0xA7 to v1.01.006 on a BMP581. When the SR-number rule says BMP581 and the firmware is LogAndStream_Shimmer3R v1.01.006, connect() no longer sends 0xA7. That version NACKs it, so the SR rule decides instead, as the Java driver's readPressureCalibrationCoefficients() does. Since DEV-982: handle NACK from a Shimmer3 instead of leaving the caller suspended #18 merged, a NACK already resumes the caller, so this stops a request that is known to be refused. It isn't what fixes the hang.

  • NaN for a BMP390 without coefficients. On a Shimmer3R, calibrated pressure and temperature are now NaN when there are no coefficients. Java does the same (DEV-1125). Until now they came out as about 0 °C and 30 kPa (the clamp of all-zero coefficients) in three cases:

    • before any 0xA6 reply;
    • after an SR-rule fallback to the BMP390;
    • from an all-0x00 or all-0xFF block, which is no longer kept as coefficients.

    Raw values are unchanged.

  • BMP180/BMP280 IDs refused on a Shimmer3R. A Shimmer3R whose 0xA6 reply names a BMP180 or BMP280 is refused, and the SR rule decides, as in Java.

The rule is PressureTempSensor.readsPressureCalibrationCoefficients, so XCTest can reach it. Shimmer3Protocol.connect() only calls it.

Testing

  • xcodebuild test -scheme ShimmerBluetoothTests, run locally on macOS (Xcode 26.6): 60 tests passed, 0 failed.
    • New: testReadsPressureCalibrationCoefficients and testBMP390WithoutCoefficients.
    • Extended: testPressureCalibrationResponse now covers the refused IDs.
  • The library also type-checks against the iOS 26.5 SDK.
  • Not covered: the change inside connect() is untested. XCTest can't construct Shimmer3Protocol (see AGENTS.md), and nothing has run on hardware.

Hardware check

  • A BMP581 board on v1.01.007 or later: 0xA6 is 01 03, the log says "Pressure sensor: BMP581", and pressure is about 100 kPa.
  • A BMP581 board on v1.01.006: no 0xA7 is sent, the log says "Pressure sensor from SR number: BMP581", and connect completes.
  • A BMP390 board: 0xA6 carries ID 2 and 21 bytes, and its values match what it reported before.

Other APIs

  • Java: already does all three.
  • C#: sends 0xA7 on v1.01.006 and falls back when it is refused, so it doesn't need the skip. It still reports BMP390 values without coefficients (DEV-1127).
  • TypeScript: falls back the same way, and returns null without coefficients.

🤖 Generated with Claude Code

Three differences from the Java driver (ShimmerBluetooth and
CalibDetailsBmp390) that the BMP581 support left in:

- 0xA7 is not sent to LogAndStream_Shimmer3R v1.01.006 when the SR-number
  rule says BMP581: that version NACKs it, and the SR rule decides instead,
  as readPressureCalibrationCoefficients() in the Java driver does.
  The NACK handling from DEV-982 already stops the hang; this stops asking.
- A Shimmer3R BMP390 without coefficients reports NaN for calibrated
  pressure and temperature (Java DEV-1125). It reported about 0 degC and
  30 kPa, the clamp of all-zero coefficients, before any 0xA6 reply, after
  an SR-rule fallback to the BMP390, or from an all-0x00/0xFF block, which
  is no longer kept as coefficients. Raw values are unchanged.
- A Shimmer3R's 0xA6 naming a BMP180 or BMP280 is refused, so the SR rule
  decides, as in the Java driver.

The rule lives in PressureTempSensor, where XCTest can reach it; connect()
only calls it. XCTests: the skip rule's version cases, the NaN cases
(no reply, SR fallback, all-0x00, all-0xFF) against real coefficients, and
the refused IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JongChern
JongChern merged commit 5d8e544 into main Nov 5, 2026
1 check passed
@JongChern
JongChern deleted the DEV-1108_follow_java_pressure_sensor_id branch November 5, 2026 02:38
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.

3 participants