0x1000 · batteryStatus
旧版电量状态功能会报告放电读数、下一个阈值和充电状态,供没有 unifiedBattery 的设备使用。
batteryStatus 是 MX Master 2S 等设备的旧版电量来源。
它报告电量读数、下一个较低阈值和充电状态。
当 0x1004 unifiedBattery 缺席时,OpenLogi 会选择此功能。
**规格:**Logitech HID++ 2.0 —— x1000 batteryStatus。**交叉核对:**Logi Options+ 2.8(静态分析)、Linux HID++ 驱动程序、Solaar。**用于:**设备清单和
openlogi list。
函数参考
BatteryStatusFeature(0x1000)实现一个请求方法。
方法
| 函数 | HID++ fn | 签名 | 返回值 |
|---|---|---|---|
get_battery_level_status | 0 | () | LegacyBatteryInfo |
is_status_broadcast | 事件辅助方法 | (function_id: u8) | bool |
get_battery_level_status 是异步方法,返回 Result<LegacyBatteryInfo, Hidpp20Error>。
此封装器未实现 getBatteryCapability(function 1)。
类型
LegacyBatteryInfo
| 字段 | 类型 | 说明 |
|---|---|---|
discharge_level | u8 | 当 status 为 Discharging 时的电量读数。固件以粗略步长报告。其他状态的零表示未知。 |
next_level | u8 | 固件将报告的下一个较低电量步长。 |
status | LegacyBatteryStatus | 当前电池充电状态。 |
LegacyBatteryStatus
| 变体 | 值 | 说明 |
|---|---|---|
Discharging | 0 | 电池正在放电。 |
Recharging | 1 | 电池正在充电。 |
AlmostFull | 2 | 电池正在充电且接近充满。 |
Full | 3 | 电池已充满。 |
SlowRecharge | 4 | 电池以低于正常的速率充电。 |
InvalidBattery | 5 | 电池类型无效。 |
ThermalError | 6 | 电池子系统报告温度错误。 |
Other | 7 | 其他充电错误。清单会将它映射为未知状态。 |
事件
此封装器未实现 EmittingFeature,也不公开类型化事件。
仅当 function 为 0 时,is_status_broadcast(function_id) 返回 true。
线格式
get_battery_level_status(fn 0)
请求:[0x00, 0x00, 0x00](没有参数)。
响应:
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | discharge_level | 粗略电量读数。放电时,0 是有效的空电量读数。非电池供电状态中,0 表示未知。 |
| 1 | next_level | 下一个较低电量步长。 |
| 2 | status | LegacyBatteryStatus,值为上表中的 0~7。 |
封装器遇到 0~7 以外的状态值时,返回 Hidpp20Error::UnsupportedResponse。
getBatteryCapability(fn 1,未实现)
Logi Options+ 会读取此响应。 OpenLogi 不会发送此 function。
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | level 数量 | 固件电量等级的数量。Options+ 2.8 |
| 1 | capability 标志 | 包含禁用屏幕提示、mileage 和可充电信息。本文不记录各位的分配。Options+ 2.8 |
| 2~3 | 标称电池寿命 | u16,BE。Options+ 2.8 |
| 4 | 危急等级 | 固件的危急电量等级值。Options+ 2.8 |
状态广播(事件 fn 0)
未请求的 function 0 报告携带与 get_battery_level_status 相同的 3 个字节。
该报告表示电量读数或充电状态已经变化。
OpenLogi 的用法
清单按 0x1004、0x1000、0x1001、0x1F20 的顺序选择电量来源。
OpenLogi 将放电读数映射为百分比和本地电量等级。
从 v0.8.14 起,PR #1768 将非电池供电状态的零映射为无百分比。
它将读数为零的 Full 映射为 100% 和 Full。
其他非电池供电状态的零读数会变成未知等级。
OpenLogi 不读取 function 1。
因此,它使用固定的 0~19、20~49、50~89 和 90~100 显示等级。
这些等级不使用设备 capability 的 level 数量或 mileage 标志。
从 v0.8.14 起,PR #1787 会记录此功能的运行时索引。
未请求的 software-ID 0、function 0 报告会排队一个合并后的清单重协调。
OpenLogi 会重新读取权威状态,不会信任事件负载。
OpenLogi 只读取此功能。
Rust 用法
use hidpp::{
device::Device,
feature::battery_status::BatteryStatusFeature,
};
// `channel` 和 `device_index` 用于标识已打开的 HID++ 设备。
let mut device = Device::new(channel, device_index).await?;
device.enumerate_features().await?;
if let Some(feature) = device.get_feature::<BatteryStatusFeature>() {
let info = feature.get_battery_level_status().await?;
println!("level={} status={:?}", info.discharge_level, info.status);
}