Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/devices/protocols/hidpp_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ class HIDPPDevice : public HIDDevice {
// Extract voltage from bytes 4 and 5 (big-endian)
uint16_t voltage = (static_cast<uint16_t>(response[4]) << 8) | response[5];

// Check if voltage is below the minimum valid calibrated voltage for the device.
// If the measured voltage is below this threshold, the headset is likely offline or the reading is invalid.
// This check applies to all HID++ devices using this generic battery request method.
if (voltage < calibration.voltages.back()) {
return BatteryResult {
.level_percent = -1,
.status = BATTERY_UNAVAILABLE,
.voltage_mv = static_cast<int>(voltage),
.raw_data = response,
.query_duration = duration
};
}

// Estimate battery percentage using spline interpolation
int level = headsetcontrol::spline_battery_level(
calibration.percentages,
Expand Down
Loading