From 33bb433d7ecb8f3dbb1d71b1c1c1fd8e31c22682 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 10 Jan 2026 19:47:03 +0100 Subject: [PATCH] always set valid gpio in load board profile --- src/core/system.cpp | 2 ++ src/web/WebSettingsService.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 5dbffa5a2..c8dbed8b8 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -2447,9 +2447,11 @@ bool System::load_board_profile(std::vector & data, const std::string & } else if (board_profile == "S2MINI") { data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Lolin S2 Mini // https://www.wemos.cc/en/latest/s2/s2_mini.html + set_valid_system_gpios(); } else if (board_profile == "S3MINI") { data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3 // https://lilygo.cc/products/t7-s3 + set_valid_system_gpios(); } else if (board_profile == "S32S3") { data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S3 valid_system_gpios_ = {0, 2, 5, 17, 18}; diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index b242567dd..ad6f0f60d 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -113,6 +113,13 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { reset_flags(); + // before loading new board profile free old gpios from used list to allow remapping + EMSESP::system_.remove_gpio(original_settings.led_gpio); + EMSESP::system_.remove_gpio(original_settings.dallas_gpio); + EMSESP::system_.remove_gpio(original_settings.pbutton_gpio); + EMSESP::system_.remove_gpio(original_settings.rx_gpio); + EMSESP::system_.remove_gpio(original_settings.tx_gpio); + // 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 @@ -149,13 +156,6 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { } } - // free old gpios from used list to allow remapping - EMSESP::system_.remove_gpio(original_settings.led_gpio); - EMSESP::system_.remove_gpio(original_settings.dallas_gpio); - EMSESP::system_.remove_gpio(original_settings.pbutton_gpio); - EMSESP::system_.remove_gpio(original_settings.rx_gpio); - EMSESP::system_.remove_gpio(original_settings.tx_gpio); - // if any of the GPIOs have changed and re-validate them bool have_valid_gpios = true; @@ -308,9 +308,9 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) { } // save the settings if changed from the webUI - // if we encountered an invalid GPIO on same boardprofile, rollback changes and don't save settings, + // 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 && original_settings.board_profile == settings.board_profile) { + if (!have_valid_gpios) { // replace settings with original settings settings = original_settings; EMSESP::system_.restore_snapshot_gpios(used_gpios, system_gpios);