Repository navigation
Conversation
|
Thanks for this well-scoped fix — the reproduction in #21749 (payload db 0f 00 decoding to 219% / charging) is clear, and the patch stays inside the connector with no new dependencies. Review notes:
The one thing code review can't verify is the provenance of the 11-point voltage-to-percentage calibration curve — whether it comes from official Bee Frontier specs and which hardware/firmware generations it applies to. Your issue notes hardware-generation applicability beyond the tested device needs confirmation; since this curve determines what users see as their battery level, that source should be confirmed by a maintainer familiar with the Bee hardware before merge. Leaving for human maintainer review to confirm the Frontier calibration curve's source and hardware-generation applicability. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
What changed and why
Fixes #21749.
Decode three-byte Bee C00F battery replies as little-endian millivolts plus charging state, instead of treating the low voltage byte as a percentage. Preserve the older two-byte percentage/charging format. Use the Bee Frontier voltage curve with linear interpolation/rounding; reject unsupported lengths and voltages outside 2500–5000 mV. Keep parsing in the existing connector: no new dependencies, generic battery clamps, UI changes, audio hooks or protocol provisioning.
The captured
db 0f 00payload currently yields 219% and charging=true; the fix yields a 76% estimate and charging=false. The low-byte-zero case (4096 mV → 80%) is covered too, so this is not a heuristic based on values exceeding 100.Product invariants affected
How it was verified
git diff --checkpassed.scripts/pr-preflight --suggestandscripts/pr-preflight --metadata-only --pr-body-file ...passed after materializing the referenced guard files. INV-CAP-1 is cited. The history-dependent failure-class ratchet explicitly skips on the shallow checkout.make preflightwas attempted, not passed: the manifest harness's platform test rejects native Android ('android' not found in {'macos', 'linux', 'windows'}), and the sparse checkout initially lacked unrelated inputs. Upstream full CI still needs maintainer approval for this fork contribution.{'level': 219, 'is_charging': true}against expected{'level': 76, 'is_charging': false}.dart analyzeon the parser and test: No issues found.Tests
app/test/unit/bee_battery_response_test.dartdirectly exercises the productionBeeDeviceConnectionparser with a transport that throws on unexpected I/O:Focused command:
cd app && flutter test test/unit/bee_battery_response_test.dart.Calibration provenance and limits
The calibration points and voltage-format charging semantics were identified by inspecting the Bee Android client's battery calculator during diagnosis; this patch independently implements the numerical mapping, without copying proprietary source or attaching disassembly/APKs. The observed packet is from one device. Generic cached model labels do not independently establish hardware generation; maintainer review of calibration applicability is requested. Voltage-to-percentage is an estimate, not measured remaining capacity. This PR does not reproduce the Bee client's history-dependent discharge filter.
The analogous macOS parser is noted in the issue but deliberately left for separate work; no Mac runtime claim. Encrypted-audio support and #20828 are also out of scope.
UI evidence
UI-Evidence: none -- protocol parser and hermetic test change only; no widget/layout changes. Sanitized packet reproduction is in #21749.
Failure class (fixes)
Failure-Class: none
The advisory classes selected by scope concern async errors, timezone assumptions, analyzer gates, teardown and synthetic telemetry; none describes this real battery wire-format mismatch. No registry or new CI guard is added.