Skip to content

fix(hid): support 0x1001 BatteryVoltage in diag battery (#688) - #741

Open
Liyfez wants to merge 1 commit into
AprilNEA:masterfrom
Liyfez:fix/battery-diag-voltage-feature
Open

fix(hid): support 0x1001 BatteryVoltage in diag battery (#688)#741
Liyfez wants to merge 1 commit into
AprilNEA:masterfrom
Liyfez:fix/battery-diag-voltage-feature

Conversation

@Liyfez

@Liyfez Liyfez commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #688

type: bug area: hid platform: all

Summary of Changes

  • Updated read_battery_raw in openlogi-hid to probe 0x1001 BatteryVoltage when neither 0x1004 UnifiedBattery nor 0x1000 BatteryStatus is exposed by the device.
  • Included 0x1001 in openlogi diag battery's candidate device filter list (openlogi-cli).
  • Updated CLI documentation to reflect 0x1001 fields (voltage_mv, status, critical).
  • Added unit tests in crates/openlogi-hid/src/write/tests.rs with ScriptedRawHidChannel verifying raw diagnostic output for 0x1004, 0x1000, 0x1001, and the unsupported fallback error.

Testing

  • cargo fmt --all -- --check passed.
  • cargo clippy --workspace --all-targets -- -D warnings passed with 0 warnings.
  • cargo test --workspace passed all test suites (including openlogi-hid, openlogi-cli, openlogi-ui locale parity, and openlogi-ipc wire format tests).

- Update 
ead_battery_raw in openlogi-hid to probe
@Liyfez
Liyfez requested a review from AprilNEA as a code owner August 21, 2026 07:16
@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extends the raw battery diagnostic to support HID++ 0x1001 BatteryVoltage devices.

  • Adds 0x1001 to CLI battery-device filtering and command documentation.
  • Probes battery features in the order 0x1004, 0x1000, then 0x1001.
  • Reports voltage, charging status, and critical state for 0x1001.
  • Adds scripted coverage for all three supported battery features and the unsupported fallback.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The new device filter, feature-probing fallback, typed BatteryVoltage decode, and scripted protocol responses are consistent with the existing HID++ abstractions and preserve the established preference for richer battery features.

Important Files Changed

Filename Overview
crates/openlogi-hid/src/write/diagnostics.rs Refactors raw battery reads into a testable helper and adds a correctly typed 0x1001 fallback after the existing preferred features.
crates/openlogi-hid/src/write/tests.rs Adds scripted coverage matching the HID++ function indices and payload layouts for all supported battery-report variants.
crates/openlogi-cli/src/cmd/diag/battery.rs Expands device filtering and documentation so 0x1001-only devices can run the battery diagnostic.
crates/openlogi-cli/src/cmd/diag.rs Updates command help to advertise all three supported battery-report formats.

Sequence Diagram

sequenceDiagram
    participant CLI as openlogi diag battery
    participant Selector as Device selector
    participant HID as Battery diagnostic
    participant Device as HID++ device
    CLI->>Selector: Find device with 0x1000, 0x1001, or 0x1004
    Selector-->>CLI: Device route
    CLI->>HID: read_battery_raw(route)
    HID->>Device: Probe 0x1004 UnifiedBattery
    alt 0x1004 supported
        Device-->>HID: Percentage, level, status
    else unsupported
        HID->>Device: Probe 0x1000 BatteryStatus
        alt 0x1000 supported
            Device-->>HID: Discharge level, next level, status
        else unsupported
            HID->>Device: Probe 0x1001 BatteryVoltage
            Device-->>HID: Voltage, status, critical
        end
    end
    HID-->>CLI: Formatted raw report
Loading

Reviews (1): Last reviewed commit: "fix(hid): support 0x1001 BatteryVoltage ..." | Re-trigger Greptile

@AprilNEA AprilNEA added type: bug Something is broken or behaves incorrectly area: hid HID device discovery, permissions, reads, or writes platform: all Cross-platform issue labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: hid HID device discovery, permissions, reads, or writes platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openlogi diag battery cannot read a 0x1001-only device, and blames the wrong feature

2 participants