Repository navigation
fix(c-api): declare the battery status values hsc_get_battery() returns - #601
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
hsc_get_battery() casts the C++ battery_status straight into hsc_battery_status_t, but the header declared the legacy values (-1/-2/0/-100/-101) while the library hands out 0-4. A charging headset reported 1, which matches no constant, and an unavailable one reported 0, which the header calls HSC_BATTERY_AVAILABLE. The C sample in LIBRARY_USAGE.md never saw HSC_BATTERY_CHARGING, and the Python sample's BatteryStatus(battery.status) raised for an ordinary available battery. Declare the values the library has always returned instead of translating them, so existing binaries, including ones that worked around the mismatch with the raw numbers, see no change, while code using the named constants starts working. static_asserts keep the two enums in step, and the library API test now checks the status for an available and a charging battery.
ChrisLauinger77
force-pushed
the
fix/c-api-battery-status
branch
2 times, most recently
from
October 22, 2026 15:36
a77b66e to
e5c2bce
Compare
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes made
hsc_get_battery()casts the C++battery_statusstraight intohsc_battery_status_t, butheadsetcontrol_c.hdeclared the legacy values (-1/-2/0/-100/-101) while the library hands out 0-4:HSC_BATTERY_AVAILABLESo the C sample in
LIBRARY_USAGE.mdnever sawHSC_BATTERY_CHARGING, and the Python sample'sBatteryStatus(battery.status)raisedValueErrorfor an ordinary available battery.static_asserts keep the C and C++ enums in step.BatteryStatususes the real values.Checklist
For new features in HeadsetControl: I discussed it beforehand in Issues or Discussions and adhered to the wikiNot applicable: this is a fix and adds no new capability.