Skip to content

Keep mouse battery levels up to date with device notifications - #1389

Merged
lujjjh merged 1 commit into
mainfrom
fix/battery-refresh-while-charging
Sep 12, 2026
Merged

lujjjh merged 1 commit into
mainfrom
fix/battery-refresh-while-charging

Conversation

@lujjjh

@lujjjh lujjjh commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Mouse battery readings could remain stale because Bluetooth updates depended on infrequent activity-triggered queries, while receiver battery values were primarily refreshed during device discovery.

Read the battery once per connection, then update it from device notifications.

Changes

  • Support Logitech HID++ battery notifications over Bluetooth and USB receivers.
  • Add standard BLE Battery Service reads and notification subscriptions through CoreBluetooth.
  • Match BLE peripherals using serial numbers or unambiguous USB vendor/product IDs, rather than device names.
  • Reinitialize observations on reconnect and discard stale callbacks and initial-read results.
  • Share receiver reports without consuming notifications needed by existing connection and button handlers.
  • Remove periodic HID++ battery queries and activity-triggered refreshes. Retain the existing refresh of OS-maintained battery properties.
  • Add the Bluetooth permission description and entitlement.

Validation

  • Release build passed with signing disabled.
  • 137 related tests passed with Thread Sanitizer enabled.
  • Disabling HID++ notification handling caused the corresponding charging-update and stale-response tests to fail.

Tested with an MX Master 3S B:

Connection Initial reading Observed notifications
Bluetooth GATT 85% Battery Level notifications during charging cable changes
Bluetooth HID++ 85% Charging and discharging transitions
Bolt receiver HID++, slot 2 85% Charging and discharging transitions

Limitations

The percentage remained at 85% during the hardware tests; charging-state transitions and notification delivery were verified, but a percentage increase was not observed.

Hardware testing used transport probes, including the production HID++ observer and GATT adapter. The installed app's complete status-bar UI flow was not exercised.

Notification availability depends on the device. This change does not add periodic battery polling for devices that lack notification support.

Related issues

@lujjjh lujjjh added the bug Something isn't working label Sep 12, 2026
@lujjjh
lujjjh merged commit 29800a6 into main Sep 12, 2026
1 check passed
@lujjjh
lujjjh deleted the fix/battery-refresh-while-charging branch September 12, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant