always set valid gpio in load board profile

This commit is contained in:
MichaelDvP
2026-01-10 19:47:03 +01:00
parent 6fc3bf30b6
commit 33bb433d7e
2 changed files with 11 additions and 9 deletions

View File

@@ -2447,9 +2447,11 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
} else if (board_profile == "S2MINI") { } else if (board_profile == "S2MINI") {
data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Lolin S2 Mini 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 // https://www.wemos.cc/en/latest/s2/s2_mini.html
set_valid_system_gpios();
} else if (board_profile == "S3MINI") { } else if (board_profile == "S3MINI") {
data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3 data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3
// https://lilygo.cc/products/t7-s3 // https://lilygo.cc/products/t7-s3
set_valid_system_gpios();
} else if (board_profile == "S32S3") { } else if (board_profile == "S32S3") {
data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S3 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}; valid_system_gpios_ = {0, 2, 5, 17, 18};

View File

@@ -113,6 +113,13 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
reset_flags(); 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 // 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 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 // 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 // if any of the GPIOs have changed and re-validate them
bool have_valid_gpios = true; bool have_valid_gpios = true;
@@ -308,9 +308,9 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
} }
// save the settings if changed from the webUI // 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 // 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 // replace settings with original settings
settings = original_settings; settings = original_settings;
EMSESP::system_.restore_snapshot_gpios(used_gpios, system_gpios); EMSESP::system_.restore_snapshot_gpios(used_gpios, system_gpios);