mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-04-30 20:45:13 +00:00
upload warnings
This commit is contained in:
@@ -502,9 +502,9 @@ void WebSettings::set_board_profile(WebSettings & settings) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
uint32_t psram_size = ESP.getPsramSize() / 1024; // in KB
|
||||
if (psram_size > 0) {
|
||||
EMSESP::logger().info("Loaded board profile %s, PSRAM: %lu KB", settings.board_profile.c_str(), psram_size);
|
||||
EMSESP::logger().info("Loaded board profile %s (PSRAM: %lu KB)", settings.board_profile.c_str(), psram_size);
|
||||
} else {
|
||||
EMSESP::logger().info("Loaded board profile %s, PSRAM: not available", settings.board_profile.c_str());
|
||||
EMSESP::logger().info("Loaded board profile %s (PSRAM: not available)", settings.board_profile.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -217,7 +217,8 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
||||
EMSESP::mqtt_.reset_mqtt();
|
||||
ok = true;
|
||||
} else if (action == "upgradeImportantMessages") {
|
||||
ok = upgradeImportantMessages(root, param);
|
||||
root["upgradeImportantMessageType"] = upgradeImportantMessages(param);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
|
||||
@@ -242,65 +243,65 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
||||
// action = upgradeImportantMessages
|
||||
// returns the type of upgrade important message to display in the UI
|
||||
// 0 = no message (if just a minor version upgrade)
|
||||
// 1 = going from <= 3.8 to 3.9 (new partition layout)
|
||||
// 1 = going from <= 3.8 to 3.9 (has new partition layout)
|
||||
// 2 = major version upgrade
|
||||
// version can be like 3.8.2 or a filename like EMS-ESP-3_8_2-dev_13-ESP32-16MB+.bin
|
||||
bool WebStatusService::upgradeImportantMessages(JsonObject root, std::string & version) {
|
||||
uint8_t WebStatusService::upgradeImportantMessages(std::string & version) {
|
||||
if (version.empty()) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t upgradeImportantMessageType = 0;
|
||||
|
||||
// it's a filename with a .bin extension, try and extract the version from it
|
||||
// it's a filename with a .bin or .md extension, try and extract the version from it
|
||||
// e.g. EMS-ESP-3_8_2-dev_13-ESP32-16MB+.bin -> major=3 minor=8 patch=2
|
||||
version::Semver200_version latest_version;
|
||||
if (version.find(".bin") != std::string::npos) {
|
||||
// e.g. EMS-ESP-3_8_2-dev_13-ESP32-16MB+.bin -> major=3 minor=8 patch=2
|
||||
if ((version.find(".bin") != std::string::npos) || (version.find(".md") != std::string::npos)) {
|
||||
std::string filename = version;
|
||||
auto pos = filename.find("EMS-ESP-");
|
||||
if (pos == std::string::npos) {
|
||||
EMSESP::logger().err("Invalid version string: %s", version.c_str());
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pos += 8; // skip past "EMS-ESP-"
|
||||
auto underscore1 = filename.find('_', pos);
|
||||
auto underscore2 = filename.find('_', underscore1 + 1);
|
||||
auto dash = filename.find('-', underscore2 + 1);
|
||||
if (underscore1 == std::string::npos || underscore2 == std::string::npos || dash == std::string::npos) {
|
||||
EMSESP::logger().err("Invalid version string: %s", version.c_str());
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string major_version = filename.substr(pos, underscore1 - pos);
|
||||
std::string minor_version = filename.substr(underscore1 + 1, underscore2 - underscore1 - 1);
|
||||
std::string patch_version = filename.substr(underscore2 + 1, dash - underscore2 - 1);
|
||||
latest_version = version::Semver200_version(major_version + "." + minor_version + "." + patch_version);
|
||||
} else {
|
||||
latest_version = version::Semver200_version(version);
|
||||
}
|
||||
|
||||
// check if it's a valid version string
|
||||
if (!latest_version.major()) {
|
||||
EMSESP::logger().err("Invalid version string: %s", version.c_str());
|
||||
return false;
|
||||
// if it's .json file exit
|
||||
if (version.find(".json") != std::string::npos) {
|
||||
return 0;
|
||||
} else {
|
||||
// treat it like a version string like "3.9.0"
|
||||
latest_version = version::Semver200_version(version);
|
||||
}
|
||||
}
|
||||
|
||||
version::Semver200_version current_version(current_version_s); // get current version
|
||||
|
||||
if (current_version.major() <= 3 && current_version.minor() <= 8) {
|
||||
upgradeImportantMessageType = 1; // if moving from below 3.8.x to 3.9.x return 1
|
||||
} else if (latest_version > current_version && current_version.minor() < latest_version.minor()) {
|
||||
upgradeImportantMessageType = 0; // if it's just a minor version upgrade return 0
|
||||
} else if (latest_version > current_version && current_version.major() < latest_version.major()) {
|
||||
upgradeImportantMessageType = 2; // if it's a major version upgrade return 2
|
||||
if (latest_version > current_version && current_version.minor() < latest_version.minor()) {
|
||||
return 0; // if it's just a minor version upgrade return 0
|
||||
}
|
||||
|
||||
// #if defined(EMSESP_DEBUG)
|
||||
// EMSESP::logger().debug("upgradeImportantMessageType: %s %d", version.c_str(), upgradeImportantMessageType);
|
||||
// #endif
|
||||
if ((current_version.major() <= 3 && current_version.minor() <= 8) && (latest_version.major() == 3 && latest_version.minor() == 9)) {
|
||||
return 1; // if moving from below 3.8.x to 3.9.x return 1
|
||||
}
|
||||
|
||||
root["upgradeImportantMessageType"] = upgradeImportantMessageType;
|
||||
if (latest_version > current_version && current_version.major() < latest_version.major()) {
|
||||
return 2; // if it's a major version upgrade return 2
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0; // if it's not a valid version upgrade return 0
|
||||
}
|
||||
|
||||
// action = checkUpgrade
|
||||
|
||||
@@ -30,13 +30,13 @@ class WebStatusService {
|
||||
SecurityManager * _securityManager;
|
||||
|
||||
// actions
|
||||
bool checkUpgrade(JsonObject root, std::string & latest_version);
|
||||
bool exportData(JsonObject root, std::string & type);
|
||||
bool getCustomSupport(JsonObject root);
|
||||
bool uploadURL(const char * url);
|
||||
bool setSystemStatus(const char * status);
|
||||
void allvalues(JsonObject output);
|
||||
bool upgradeImportantMessages(JsonObject root, std::string & version);
|
||||
bool checkUpgrade(JsonObject root, std::string & latest_version);
|
||||
bool exportData(JsonObject root, std::string & type);
|
||||
bool getCustomSupport(JsonObject root);
|
||||
bool uploadURL(const char * url);
|
||||
bool setSystemStatus(const char * status);
|
||||
void allvalues(JsonObject output);
|
||||
uint8_t upgradeImportantMessages(std::string & version);
|
||||
|
||||
std::string current_version_s = EMSESP_APP_VERSION;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user