fix setting default version

This commit is contained in:
proddy
2026-01-05 21:35:39 +01:00
parent cff4bd0a71
commit bf5990a992

View File

@@ -96,9 +96,7 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
std::vector<int8_t> system_gpios;
EMSESP::system_.make_snapshot_gpios(used_gpios, system_gpios);
reset_flags();
settings.version = root["version"] | EMSESP_DEFAULT_VERSION; // save the version, we use it later in System::check_upgrade()
settings.version = root["version"] | EMSESP_APP_VERSION; // save the version, we use it later in System::check_upgrade()
settings.board_profile = root["board_profile"] | EMSESP_DEFAULT_BOARD_PROFILE;
// get current values that are related to the board profile
@@ -113,6 +111,8 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
settings.eth_clock_mode = root["eth_clock_mode"];
settings.led_type = root["led_type"]; // 1 = RGB-LED
reset_flags();
// see if the user has changed the board profile
// this will set: led_gpio, dallas_gpio, rx_gpio, tx_gpio, pbutton_gpio, phy_type, eth_power, eth_phy_addr, eth_clock_mode, led_type
// this will always run when EMS-ESP starts since original_settings{} is empty
@@ -307,6 +307,7 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
// save the settings if changed from the webUI
// if we encountered an invalid GPIO, rollback changes and don't save settings, and report the error to WebUI
// without a restart
if (!have_valid_gpios) {
// replace settings with original settings
settings = original_settings;
@@ -320,7 +321,8 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
// save the setting internally, for reference later
EMSESP::system_.store_settings(settings);
if (has_flags(WebSettings::ChangeFlags::RESTART)) {
// and finally always write to the settings file
if (has_flags(ChangeFlags::RESTART)) {
return StateUpdateResult::CHANGED_RESTART;
}