0x1004 · unifiedBattery
Modern unified battery feature — query charge percentage, coarse level, and charging status, with live push events.
The modern, unified battery feature — one call for percentage, a coarse level,
and charge status, replacing the older 0x1000 batteryStatus / 0x1001
batteryVoltage features. getBatteryCapabilities reports what the device can
measure; getBatteryInfo returns the charging percentage, a BatteryLevel
(full / good / low / critical), and a BatteryStatus (charging, discharging,
…). The feature also emits live updates as the device pushes them.
OpenLogi reads it for the battery percentage and charge state shown in the device
carousel and the list inventory.
Spec: Logitech HID++ 2.0 — x1004 unifiedBattery. Used by: battery percentage / charge state.
Function reference
The UnifiedBatteryFeature wrapper (0x1004) exposes:
Methods
| Function | HID++ fn | Signature | Returns |
|---|---|---|---|
get_battery_capabilities | 0 | () | BatteryCapabilities |
get_battery_info | 1 | () | BatteryInfo |
listen | event | () | Receiver<BatteryEvent> |
get_battery_capabilities and get_battery_info are async and return Result<…, Hidpp20Error>. listen is synchronous and returns a channel receiver directly.
Types
BatteryCapabilities
Represents the capabilities of this feature and the battery itself.
| Field | Type | Description |
|---|---|---|
reported_levels | HashSet<BatteryLevel> | All BatteryLevel variants the feature supports and reports. |
rechargeable | bool | Whether the battery is rechargeable. |
percentage | bool | Whether the device supports reporting the current charge percentage in BatteryInfo::charging_percentage. |
BatteryInfo
Represents information about the current battery charge.
| Field | Type | Description |
|---|---|---|
charging_percentage | u8 | The current charge of the battery in percent. Always zero if BatteryCapabilities::percentage is false. |
level | BatteryLevel | The current (approximate) level of the battery. |
status | BatteryStatus | The current charging status of the battery. |
BatteryLevel
Represents an approximate level of the battery charge.
| Variant | Value | Description |
|---|---|---|
Critical | 1 | Critical battery level. |
Low | 2 | Low battery level. |
Good | 4 | Good battery level. |
Full | 8 | Full battery level. |
BatteryStatus
Represents the charging status of the battery.
| Variant | Value | Description |
|---|---|---|
Discharging | 0 | Battery is discharging. |
Charging | 1 | Battery is charging. |
ChargingSlow | 2 | Battery is charging slowly. |
Full | 3 | Battery is full. |
Error | 4 | Battery subsystem reported an error. |
Events
UnifiedBatteryFeature implements EmittingFeature<BatteryEvent>. Call listen() to obtain a channel receiver that yields BatteryEvent values pushed by the device.
BatteryEvent
| Variant | Payload | Description |
|---|---|---|
InfoUpdate | BatteryInfo | Emitted whenever the battery information changes. Always enabled. |
Wire format
Both request payloads are 3 zero bytes; the device replies with a 16-byte long-format payload and the crate reads the first few bytes via extend_payload().
get_battery_capabilities (fn 0)
Request: [0x00, 0x00, 0x00] (no parameters)
Response (byte → field):
| Byte | Field | Notes |
|---|---|---|
| 0, bit 0 | reported_levels contains Critical | set if payload[0] & 0x01 != 0 |
| 0, bit 1 | reported_levels contains Low | set if payload[0] & 0x02 != 0 |
| 0, bit 2 | reported_levels contains Good | set if payload[0] & 0x04 != 0 |
| 0, bit 3 | reported_levels contains Full | set if payload[0] & 0x08 != 0 |
| 1, bit 0 | rechargeable | set if payload[1] & 0x01 != 0 |
| 1, bit 1 | percentage | set if payload[1] & 0x02 != 0 |
get_battery_info (fn 1)
Request: [0x00, 0x00, 0x00] (no parameters)
Response (byte → field):
| Byte | Field | Notes |
|---|---|---|
| 0 | charging_percentage | raw u8; zero when BatteryCapabilities::percentage is false |
| 1 | level | BatteryLevel enum value (1 = Critical, 2 = Low, 4 = Good, 8 = Full) |
| 2 | status | BatteryStatus enum value (0 = Discharging … 4 = Error) |
| 3 | (external power source indicator) | not decoded by the crate; see Linux driver notes in source |
InfoUpdate event (fn 0, event sub-id 0)
The device pushes this event unsolicited whenever battery state changes. The crate's message listener parses it identically to get_battery_info:
| Byte | Field | Notes |
|---|---|---|
| 0 | charging_percentage | raw u8 |
| 1 | level | BatteryLevel enum value |
| 2 | status | BatteryStatus enum value |
Usage (Rust)
use hidpp::{
device::Device,
feature::{EmittingFeature, unified_battery::UnifiedBatteryFeature},
};
// device: &mut Device, already created via Device::new(channel, index)
device.enumerate_features().await?;
if let Some(feat) = device.get_feature::<UnifiedBatteryFeature>() {
// Query static capabilities once
let caps = feat.get_battery_capabilities().await?;
println!("rechargeable={}, percentage={}", caps.rechargeable, caps.percentage);
// Poll current state
let info = feat.get_battery_info().await?;
println!("{}% — {:?} / {:?}", info.charging_percentage, info.level, info.status);
// Subscribe to live updates pushed by the device
let rx = feat.listen();
while let Ok(event) = rx.recv().await {
println!("battery event: {:?}", event);
}
}0x1001 · batteryVoltage
Legacy battery feature that exposes raw voltage and a coarse charge level — superseded by 0x1004 unifiedBattery.
0x1010 · chargingControl
Read and configure a rechargeable device's charging behaviour — including charge-limit modes that cap the maximum charge level for battery health.