mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
add install date to firmware versions
This commit is contained in:
@@ -301,10 +301,11 @@ void System::get_partition_info() {
|
||||
|
||||
#ifdef EMSESP_STANDALONE
|
||||
// dummy data for standalone mode
|
||||
partition_info_["app0"] = {EMSESP_APP_VERSION, 0};
|
||||
partition_info_["app1"] = {"", 0};
|
||||
partition_info_["factory"] = {"", 0};
|
||||
partition_info_["boot"] = {"", 0};
|
||||
// version, size, install_date
|
||||
partition_info_["app0"] = {EMSESP_APP_VERSION, 0, ""};
|
||||
partition_info_["app1"] = {"", 0, ""};
|
||||
partition_info_["factory"] = {"", 0, ""};
|
||||
partition_info_["boot"] = {"", 0, ""};
|
||||
#else
|
||||
|
||||
auto current_partition = (const char *)esp_ota_get_running_partition()->label;
|
||||
@@ -337,14 +338,27 @@ void System::get_partition_info() {
|
||||
|
||||
// get the version from the NVS store, and add to map
|
||||
if (is_valid) {
|
||||
PartitionInfo info;
|
||||
info.size = part->size / 1024; // in KB
|
||||
PartitionInfo p_info;
|
||||
p_info.size = part->size / 1024; // set size in KB
|
||||
|
||||
// get version from NVS, if not found, use empty string
|
||||
if (EMSESP::nvs_.isKey(part->label)) {
|
||||
info.version = EMSESP::nvs_.getString(part->label).c_str();
|
||||
p_info.version = EMSESP::nvs_.getString(part->label).c_str();
|
||||
} else {
|
||||
info.version = ""; // no version, empty string
|
||||
p_info.version = "";
|
||||
}
|
||||
partition_info_[part->label] = info;
|
||||
|
||||
// get install date from NTP if active and add
|
||||
if (ntp_connected_) {
|
||||
char time_string[25];
|
||||
time_t now = time(nullptr) - uuid::get_uptime_sec();
|
||||
strftime(time_string, sizeof(time_string), "%FT%T%z", localtime(&now));
|
||||
p_info.install_date = time_string;
|
||||
} else {
|
||||
p_info.install_date = "";
|
||||
}
|
||||
|
||||
partition_info_[part->label] = p_info;
|
||||
}
|
||||
|
||||
it = esp_partition_next(it);
|
||||
|
||||
@@ -77,6 +77,7 @@ enum FUSE_VALUE : uint8_t { ALL = 0, MFG = 1, MODEL = 2, BOARD = 3, REV = 4, BAT
|
||||
struct PartitionInfo {
|
||||
std::string version;
|
||||
size_t size;
|
||||
std::string install_date; // optional, only available if NTP is connected
|
||||
};
|
||||
|
||||
class System {
|
||||
@@ -370,9 +371,10 @@ class System {
|
||||
|
||||
static void remove_gpio(uint8_t pin, bool also_system = false); // remove a gpio from both valid (optional) and used lists
|
||||
|
||||
// Partition info map: partition name -> {version, size}
|
||||
// Partition info map: partition name -> {version, size, install_date}
|
||||
std::map<std::string, PartitionInfo, std::less<>, AllocatorPSRAM<std::pair<const std::string, PartitionInfo>>> partition_info_;
|
||||
static bool set_partition(const char * partitionname);
|
||||
|
||||
static bool set_partition(const char * partitionname);
|
||||
|
||||
private:
|
||||
static uuid::log::Logger logger_;
|
||||
|
||||
@@ -154,10 +154,11 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
||||
if (partition.first == (const char *)esp_ota_get_running_partition()->label || partition.second.version.empty() || partition.second.size == 0) {
|
||||
continue;
|
||||
}
|
||||
JsonObject part = partitions.add<JsonObject>();
|
||||
part["partition"] = partition.first;
|
||||
part["version"] = partition.second.version;
|
||||
part["size"] = partition.second.size;
|
||||
JsonObject part = partitions.add<JsonObject>();
|
||||
part["partition"] = partition.first;
|
||||
part["version"] = partition.second.version;
|
||||
part["size"] = partition.second.size;
|
||||
part["install_date"] = partition.second.install_date;
|
||||
}
|
||||
|
||||
root["developer_mode"] = EMSESP::system_.developer_mode();
|
||||
|
||||
Reference in New Issue
Block a user