move has_partition and has_loader to hardware status

This commit is contained in:
proddy
2024-08-30 11:09:31 +02:00
parent 6d1e08d244
commit 5bafe6587c

View File

@@ -80,19 +80,6 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
#endif #endif
} }
#ifndef EMSESP_STANDALONE
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, nullptr);
root["has_loader"] = partition != NULL && partition != esp_ota_get_running_partition();
partition = esp_ota_get_next_update_partition(nullptr);
if (partition) {
uint64_t buffer;
esp_partition_read(partition, 0, &buffer, 8);
root["has_partition"] = (buffer != 0xFFFFFFFFFFFFFFFF);
} else {
root["has_partition"] = false;
}
#endif
response->setLength(); response->setLength();
request->send(response); request->send(response);
} }
@@ -145,6 +132,18 @@ void WebStatusService::hardwareStatus(AsyncWebServerRequest * request) {
root["model"] = EMSESP::system_.getBBQKeesGatewayDetails(); root["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
// check for a factory partition first
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, nullptr);
root["has_loader"] = partition != NULL && partition != esp_ota_get_running_partition();
partition = esp_ota_get_next_update_partition(nullptr);
if (partition) {
uint64_t buffer;
esp_partition_read(partition, 0, &buffer, 8);
root["has_partition"] = (buffer != 0xFFFFFFFFFFFFFFFF);
} else {
root["has_partition"] = false;
}
#endif #endif
response->setLength(); response->setLength();
@@ -160,7 +159,9 @@ void WebStatusService::checkUpgrade(AsyncWebServerRequest * request, JsonVariant
std::string latest_version = json["version"] | EMSESP_APP_VERSION; std::string latest_version = json["version"] | EMSESP_APP_VERSION;
version::Semver200_version this_version(latest_version); version::Semver200_version this_version(latest_version);
#ifdef EMSESP_DEBUG
emsesp::EMSESP::logger().debug("Checking for upgrade: %s > %s", EMSESP_APP_VERSION, latest_version.c_str()); emsesp::EMSESP::logger().debug("Checking for upgrade: %s > %s", EMSESP_APP_VERSION, latest_version.c_str());
#endif
root["upgradeable"] = (this_version > settings_version); root["upgradeable"] = (this_version > settings_version);