Improvement: Add Battery Pause Feature for Max Charge/Discharge Power and OTA Update Optimization

This commit is contained in:
amarofarinha 2024-09-13 15:32:54 +01:00
parent ccb2db87ec
commit 856a0838d1
23 changed files with 1004 additions and 773 deletions

View file

@ -43,6 +43,15 @@ void ElegantOTAClass::begin(ELEGANTOTA_WEBSERVER *server, const char * username,
return request->requestAuthentication();
}
// Pre-OTA update callback
if (preUpdateCallback != NULL) preUpdateCallback();
// Sleep for 3 seconds to allow asynchronous preUpdateCallback tasks to complete
unsigned long sleepStart = millis();
while (millis() - sleepStart < 3000) { // Sleep for 3 second
delay(1); // Yield to other tasks
}
// Get header x-ota-mode value, if present
OTA_Mode mode = OTA_MODE_FIRMWARE;
// Get mode from arg
@ -73,7 +82,7 @@ void ElegantOTAClass::begin(ELEGANTOTA_WEBSERVER *server, const char * username,
#endif
// Pre-OTA update callback
if (preUpdateCallback != NULL) preUpdateCallback();
//if (preUpdateCallback != NULL) preUpdateCallback();
// Start update process
#if defined(ESP8266)