Commit ffa4f23
committed
feat(battery): support legacy 0x1000 BatteryStatus and its charging quirk
Older devices such as a Bluetooth-direct MX Master 2S expose only the legacy
BatteryStatus feature (0x1000), never the unified 0x1004, so they showed no
battery at all. Implement 0x1000 mirroring the SmartShift 0x2110/0x2111 design
and have the inventory probe prefer 0x1004, falling back to 0x1000 — the same
enhanced-then-legacy order SmartShift uses. 0x1000 reports a percentage but no
level bitmask, so the coarse BatteryLevel is derived from fixed display buckets.
The 0x1000 firmware can't gauge charge under load: it reports discharge_level=0
status=Recharging while charging, which surfaced as a misleading "Charging · 0%".
Two layers handle it:
- hold_percentage_while_charging() carries the last-known percentage forward
through a charge session (frozen pre-charge value, cache only) so the reading
stays trackable once one discharge read exists.
- On a cold start (charger plugged before the app opens) there's no prior to
hold, so the GUI shows "Charging" instead of the bogus 0% across the card,
summary, and tray menu.
Adds `openlogi diag battery`, which prints the raw 0x1004/0x1000 report so a
claim like "MX2S shows 0% while charging" can be confirmed against the wire.
Verified on hardware: MX2S reports 50% (discharging) over BT-direct, and 0%
status=Recharging while charging.1 parent 45070bb commit ffa4f23
11 files changed
Lines changed: 507 additions & 68 deletions
File tree
- crates
- openlogi-cli/src/cmd/diag
- openlogi-gui/src
- openlogi-hidpp/src/feature
- battery_status
- openlogi-hid/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
817 | 817 | | |
818 | 818 | | |
819 | 819 | | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
820 | 832 | | |
821 | 833 | | |
822 | 834 | | |
823 | | - | |
| 835 | + | |
824 | 836 | | |
825 | 837 | | |
826 | 838 | | |
827 | 839 | | |
828 | | - | |
829 | | - | |
830 | | - | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
831 | 846 | | |
832 | 847 | | |
833 | 848 | | |
| |||
1338 | 1353 | | |
1339 | 1354 | | |
1340 | 1355 | | |
1341 | | - | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
1342 | 1361 | | |
1343 | 1362 | | |
1344 | 1363 | | |
| |||
1697 | 1716 | | |
1698 | 1717 | | |
1699 | 1718 | | |
1700 | | - | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1701 | 1748 | | |
1702 | 1749 | | |
1703 | 1750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
| |||
0 commit comments