Skip to content

Commit

Permalink
Fix battery status handling for non-ESP platforms
Browse files Browse the repository at this point in the history
Added proper return values for functions `getBatteryLevel()` and `isBatteryCharging()` to ensure correct battery status handling on non-ESP platforms. This change prevents incorrect battery level and charging status indications.
  • Loading branch information
Charles-Mahoudeau committed Aug 26, 2024
1 parent e935961 commit 711b087
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/gsm/src/gsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ namespace GSM
}

double getBatteryLevel() {
#ifdef ESP_PLATFORM
const float voltage = getVoltage();

if (voltage == -1) {
Expand Down Expand Up @@ -631,6 +632,9 @@ namespace GSM
// return 5;
// else
// return 0;
#else
return 1;
#endif
}

void updateHour()
Expand Down
2 changes: 1 addition & 1 deletion lib/hardware/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool hardware::isCharging() {
#ifdef ESP_PLATFORM
return analogRead(PIN_BATTERY_CHARGING_STATUS) > 100;
#else
return false;
return true;
#endif
}

Expand Down

0 comments on commit 711b087

Please sign in to comment.