mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
merge PR #923 - fixes and the tested heatpump/heatsource entities by mvdp
This commit is contained in:
@@ -17,11 +17,24 @@ void RestartService::restart(AsyncWebServerRequest * request) {
|
||||
|
||||
void RestartService::partition(AsyncWebServerRequest * request) {
|
||||
const esp_partition_t * factory_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||
if (!factory_partition) {
|
||||
if (factory_partition) {
|
||||
esp_ota_set_boot_partition(factory_partition);
|
||||
request->onDisconnect(RestartService::restartNow);
|
||||
request->send(200);
|
||||
return;
|
||||
}
|
||||
const esp_partition_t * ota_partition = esp_ota_get_next_update_partition(NULL);
|
||||
if (!ota_partition) {
|
||||
request->send(400); // bad request
|
||||
return;
|
||||
}
|
||||
esp_ota_set_boot_partition(factory_partition);
|
||||
uint64_t buffer;
|
||||
esp_partition_read(ota_partition, 0, &buffer, 8);
|
||||
if (buffer == 0xFFFFFFFFFFFFFFFF) { // partition empty
|
||||
request->send(400); // bad request
|
||||
return;
|
||||
}
|
||||
esp_ota_set_boot_partition(ota_partition);
|
||||
request->onDisconnect(RestartService::restartNow);
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user