Skip to content

fix(ui): refresh the battery level while connected - #19

Merged
AmitRajput-Dev merged 1 commit into
AmitRajput-Dev:mainfrom
ssuyash3000:fix/battery-refresh
Oct 28, 2026
Merged

AmitRajput-Dev merged 1 commit into
AmitRajput-Dev:mainfrom
ssuyash3000:fix/battery-refresh

Conversation

@ssuyash3000

Copy link
Copy Markdown
Contributor

requestBattery() only runs in the post-connect read, so the percentage in the
header is a snapshot from the moment you pressed Connect. Leave the app open
for a few hours and it still shows that first value while the real headset
drains — and on a charging headset it never climbs.

Piggyback a battery read on the existing ambient poll worker, once every ~30s
(BATTERY_POLL_FRAMES), so no extra thread or future is needed. The read is
guarded: a device that doesn't answer the inquiry keeps its stale value instead
of dropping the poll.

Verified against a simulated v2 device whose reported level changes over time:
the header follows it instead of freezing at the connect-time value.

`requestBattery()` only runs in the post-connect read, so the percentage in the
header is a snapshot from the moment you pressed Connect. Leave the app open
for a few hours and it still shows that first value while the real headset
drains — and on a charging headset it never climbs.

Piggyback a battery read on the existing ambient poll worker, once every ~30s
(`BATTERY_POLL_FRAMES`), so no extra thread or future is needed. The read is
guarded: a device that doesn't answer the inquiry keeps its stale value instead
of dropping the poll.

Verified against a simulated v2 device whose reported level changes over time:
the header follows it instead of freezing at the connect-time value.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@AmitRajput-Dev

Copy link
Copy Markdown
Owner

Merged via #30, together with the rest of your Windows/Linux fixes (#18–#22). Thank you, clear write-ups and small focused diffs made these easy to review. CI is green on Windows and Ubuntu, and they'll be in the next Windows build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants