File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 44#include < QMap>
55#include < QString>
66#include < QObject>
7+ #include < climits>
78
89#include " airpods_packets.h"
910
@@ -152,20 +153,17 @@ class Battery : public QObject
152153 auto [isRightCharging, rawRightBattery] = formatBattery (rawRightBatteryByte);
153154 auto [isCaseCharging, rawCaseBattery] = formatBattery (rawCaseBatteryByte);
154155
155- // If raw byte is 0xFF or (0x7F and charging), use the last known level
156- if (rawLeftBatteryByte == 0xFF || (rawLeftBatteryByte == 0x7F && isLeftCharging)) {
157- rawLeftBatteryByte = states.value (Component::Left).level ; // Use last valid level
156+ if (rawLeftBattery == CHAR_MAX) {
157+ rawLeftBattery = states.value (Component::Left).level ; // Use last valid level
158158 isLeftCharging = states.value (Component::Left).status == BatteryStatus::Charging;
159159 }
160160
161- // If raw byte is 0xFF or (0x7F and charging), use the last known level
162- if (rawRightBatteryByte == 0xFF || (rawRightBatteryByte == 0x7F && isRightCharging)) {
161+ if (rawRightBattery == CHAR_MAX) {
163162 rawRightBattery = states.value (Component::Right).level ; // Use last valid level
164163 isRightCharging = states.value (Component::Right).status == BatteryStatus::Charging;
165164 }
166165
167- // If raw byte is 0xFF or (0x7F and charging), use the last known level
168- if (rawCaseBatteryByte == 0xFF || (rawCaseBatteryByte == 0x7F && isCaseCharging)) {
166+ if (rawCaseBattery == CHAR_MAX) {
169167 rawCaseBattery = states.value (Component::Case).level ; // Use last valid level
170168 isCaseCharging = states.value (Component::Case).status == BatteryStatus::Charging;
171169 }
You can’t perform that action at this time.
0 commit comments