Skip to content

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

Open
ssuyash3000 wants to merge 1 commit into
AmitRajput-Dev:mainfrom
ssuyash3000:fix/battery-refresh
Open

ssuyash3000 wants to merge 1 commit into
AmitRajput-Dev:mainfrom
ssuyash3000:fix/battery-refresh

Conversation

@ssuyash3000

Copy link
Copy Markdown

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>

This branch has not been deployed

No deployments
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.

1 participant